wayland: Don't force the window into OpenGL mode if we want Vulkan.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 14 Feb 2020 01:08:21 -0500
changeset 13517fbcc6e833d3c
parent 13516 dd33a1cfaae5
child 13518 963f11dbf153
wayland: Don't force the window into OpenGL mode if we want Vulkan.
src/video/wayland/SDL_waylandwindow.c
     1.1 --- a/src/video/wayland/SDL_waylandwindow.c	Thu Feb 13 16:10:52 2020 -0800
     1.2 +++ b/src/video/wayland/SDL_waylandwindow.c	Fri Feb 14 01:08:21 2020 -0500
     1.3 @@ -118,7 +118,9 @@
     1.4          window->h = wind->resize.height;
     1.5  
     1.6          wl_surface_set_buffer_scale(wind->surface, get_window_scale_factor(window));
     1.7 -        WAYLAND_wl_egl_window_resize(wind->egl_window, window->w * get_window_scale_factor(window), window->h * get_window_scale_factor(window), 0, 0);
     1.8 +        if (wind->egl_window) {
     1.9 +            WAYLAND_wl_egl_window_resize(wind->egl_window, window->w * get_window_scale_factor(window), window->h * get_window_scale_factor(window), 0, 0);
    1.10 +        }
    1.11  
    1.12          zxdg_surface_v6_ack_configure(zxdg, serial);
    1.13  
    1.14 @@ -223,7 +225,9 @@
    1.15          window->h = wind->resize.height;
    1.16  
    1.17          wl_surface_set_buffer_scale(wind->surface, get_window_scale_factor(window));
    1.18 -        WAYLAND_wl_egl_window_resize(wind->egl_window, window->w * get_window_scale_factor(window), window->h * get_window_scale_factor(window), 0, 0);
    1.19 +        if (wind->egl_window) {
    1.20 +            WAYLAND_wl_egl_window_resize(wind->egl_window, window->w * get_window_scale_factor(window), window->h * get_window_scale_factor(window), 0, 0);
    1.21 +        }
    1.22  
    1.23          xdg_surface_ack_configure(xdg, serial);
    1.24  
    1.25 @@ -624,9 +628,11 @@
    1.26      c = _this->driverdata;
    1.27      window->driverdata = data;
    1.28  
    1.29 -    if (!(window->flags & SDL_WINDOW_OPENGL)) {
    1.30 -        SDL_GL_LoadLibrary(NULL);
    1.31 -        window->flags |= SDL_WINDOW_OPENGL;
    1.32 +    if (!(window->flags & SDL_WINDOW_VULKAN)) {
    1.33 +        if (!(window->flags & SDL_WINDOW_OPENGL)) {
    1.34 +            SDL_GL_LoadLibrary(NULL);
    1.35 +            window->flags |= SDL_WINDOW_OPENGL;
    1.36 +        }
    1.37      }
    1.38  
    1.39      if (window->x == SDL_WINDOWPOS_UNDEFINED) {
    1.40 @@ -690,14 +696,16 @@
    1.41      }
    1.42  #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
    1.43  
    1.44 -    data->egl_window = WAYLAND_wl_egl_window_create(data->surface,
    1.45 +    if (window->flags & SDL_WINDOW_OPENGL) {
    1.46 +        data->egl_window = WAYLAND_wl_egl_window_create(data->surface,
    1.47                                              window->w * data->scale_factor, window->h * data->scale_factor);
    1.48  
    1.49 -    /* Create the GLES window surface */
    1.50 -    data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
    1.51 +        /* Create the GLES window surface */
    1.52 +        data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->egl_window);
    1.53      
    1.54 -    if (data->egl_surface == EGL_NO_SURFACE) {
    1.55 -        return SDL_SetError("failed to create a window surface");
    1.56 +        if (data->egl_surface == EGL_NO_SURFACE) {
    1.57 +            return SDL_SetError("failed to create an EGL window surface");
    1.58 +        }
    1.59      }
    1.60  
    1.61      if (c->shell.xdg) {
    1.62 @@ -781,7 +789,10 @@
    1.63      struct wl_region *region;
    1.64  
    1.65      wl_surface_set_buffer_scale(wind->surface, get_window_scale_factor(window));
    1.66 -    WAYLAND_wl_egl_window_resize(wind->egl_window, window->w * get_window_scale_factor(window), window->h * get_window_scale_factor(window), 0, 0);
    1.67 +
    1.68 +    if (wind->egl_window) {
    1.69 +        WAYLAND_wl_egl_window_resize(wind->egl_window, window->w * get_window_scale_factor(window), window->h * get_window_scale_factor(window), 0, 0);
    1.70 +    }
    1.71  
    1.72      region = wl_compositor_create_region(data->compositor);
    1.73      wl_region_add(region, 0, 0, window->w, window->h);
    1.74 @@ -813,8 +824,12 @@
    1.75      SDL_WindowData *wind = window->driverdata;
    1.76  
    1.77      if (data) {
    1.78 -        SDL_EGL_DestroySurface(_this, wind->egl_surface);
    1.79 -        WAYLAND_wl_egl_window_destroy(wind->egl_window);
    1.80 +        if (wind->egl_surface) {
    1.81 +            SDL_EGL_DestroySurface(_this, wind->egl_surface);
    1.82 +        }
    1.83 +        if (wind->egl_window) {
    1.84 +            WAYLAND_wl_egl_window_destroy(wind->egl_window);
    1.85 +        }
    1.86  
    1.87          if (wind->server_decoration) {
    1.88             zxdg_toplevel_decoration_v1_destroy(wind->server_decoration);