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:
authorSam Lantinga <slouken@libsdl.org>
Tue, 16 May 2017 06:30:39 -0700
changeset 1100640ff26e5a853
parent 11005 5f5bd41b1fc6
child 11007 e75416b7aba1
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
include/SDL_video.h
src/video/SDL_video.c
src/video/android/SDL_androidwindow.c
     1.1 --- a/include/SDL_video.h	Sat May 13 23:01:04 2017 +0200
     1.2 +++ b/include/SDL_video.h	Tue May 16 06:30:39 2017 -0700
     1.3 @@ -116,7 +116,8 @@
     1.4      SDL_WINDOW_SKIP_TASKBAR  = 0x00010000,      /**< window should not be added to the taskbar */
     1.5      SDL_WINDOW_UTILITY       = 0x00020000,      /**< window should be treated as a utility window */
     1.6      SDL_WINDOW_TOOLTIP       = 0x00040000,      /**< window should be treated as a tooltip */
     1.7 -    SDL_WINDOW_POPUP_MENU    = 0x00080000       /**< window should be treated as a popup menu */
     1.8 +    SDL_WINDOW_POPUP_MENU    = 0x00080000,      /**< window should be treated as a popup menu */
     1.9 +    SDL_WINDOW_VULKAN        = 0x00100000       /**< window usable for Vulkan surface */
    1.10  } SDL_WindowFlags;
    1.11  
    1.12  /**
     2.1 --- a/src/video/SDL_video.c	Sat May 13 23:01:04 2017 +0200
     2.2 +++ b/src/video/SDL_video.c	Tue May 16 06:30:39 2017 -0700
     2.3 @@ -1321,7 +1321,7 @@
     2.4  }
     2.5  
     2.6  #define CREATE_FLAGS \
     2.7 -    (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)
     2.8 +    (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 )
     2.9  
    2.10  static void
    2.11  SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
     3.1 --- a/src/video/android/SDL_androidwindow.c	Sat May 13 23:01:04 2017 +0200
     3.2 +++ b/src/video/android/SDL_androidwindow.c	Tue May 16 06:30:39 2017 -0700
     3.3 @@ -69,13 +69,17 @@
     3.4          SDL_free(data);
     3.5          return SDL_SetError("Could not fetch native window");
     3.6      }
     3.7 -    
     3.8 -    data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window);
     3.9  
    3.10 -    if (data->egl_surface == EGL_NO_SURFACE) {
    3.11 -        ANativeWindow_release(data->native_window);
    3.12 -        SDL_free(data);
    3.13 -        return SDL_SetError("Could not create GLES window surface");
    3.14 +    /* Do not create EGLSurface for Vulkan window since it will then make the window
    3.15 +       incompatible with vkCreateAndroidSurfaceKHR */
    3.16 +    if ((window->flags & SDL_WINDOW_VULKAN) == 0) {
    3.17 +        data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window);
    3.18 +
    3.19 +        if (data->egl_surface == EGL_NO_SURFACE) {
    3.20 +            ANativeWindow_release(data->native_window);
    3.21 +            SDL_free(data);
    3.22 +            return SDL_SetError("Could not create GLES window surface");
    3.23 +        }
    3.24      }
    3.25  
    3.26      window->driverdata = data;