2014-08-09 21:35:27 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2016-01-10 04:41:52 +01:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2014-08-09 21:35:27 +02:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-02-18 07:18:58 +01:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
|
|
|
#define VK_USE_PLATFORM_WAYLAND_KHR
|
|
|
|
#include "../common/vulkan_common.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-16 05:53:34 +02:00
|
|
|
#include <sys/poll.h>
|
|
|
|
#include <unistd.h>
|
2016-02-18 07:18:58 +01:00
|
|
|
#include <signal.h>
|
2015-09-16 05:53:34 +02:00
|
|
|
|
|
|
|
#include <wayland-client.h>
|
2016-02-18 07:18:58 +01:00
|
|
|
#ifdef HAVE_EGL
|
2015-09-16 05:53:34 +02:00
|
|
|
#include <wayland-egl.h>
|
2016-02-18 07:18:58 +01:00
|
|
|
#endif
|
2015-09-16 05:53:34 +02:00
|
|
|
|
2016-01-20 06:16:55 +01:00
|
|
|
#include <string/stdstring.h>
|
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
#include "../../driver.h"
|
|
|
|
#include "../../general.h"
|
2015-03-15 02:47:23 +01:00
|
|
|
#include "../../runloop.h"
|
2016-02-18 07:18:58 +01:00
|
|
|
#ifdef HAVE_EGL
|
2015-11-19 13:16:43 +01:00
|
|
|
#include "../common/egl_common.h"
|
2016-02-18 07:18:58 +01:00
|
|
|
#endif
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
2015-11-17 08:01:33 +01:00
|
|
|
#include "../common/gl_common.h"
|
2016-02-18 07:18:58 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
static volatile sig_atomic_t g_quit = 0;
|
|
|
|
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-17 23:22:54 +01:00
|
|
|
static VkInstance cached_instance;
|
|
|
|
static VkDevice cached_device;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
|
|
|
typedef struct gfx_ctx_vulkan_data
|
|
|
|
{
|
|
|
|
struct vulkan_context context;
|
|
|
|
|
|
|
|
PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR;
|
|
|
|
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR fpGetPhysicalDeviceSurfaceCapabilitiesKHR;
|
|
|
|
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR fpGetPhysicalDeviceSurfaceFormatsKHR;
|
|
|
|
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR fpGetPhysicalDeviceSurfacePresentModesKHR;
|
|
|
|
PFN_vkCreateSwapchainKHR fpCreateSwapchainKHR;
|
|
|
|
PFN_vkDestroySwapchainKHR fpDestroySwapchainKHR;
|
|
|
|
PFN_vkGetSwapchainImagesKHR fpGetSwapchainImagesKHR;
|
|
|
|
PFN_vkAcquireNextImageKHR fpAcquireNextImageKHR;
|
|
|
|
PFN_vkQueuePresentKHR fpQueuePresentKHR;
|
|
|
|
PFN_vkCreateWaylandSurfaceKHR fpCreateWaylandSurfaceKHR;
|
|
|
|
PFN_vkDestroySurfaceKHR fpDestroySurfaceKHR;
|
|
|
|
|
|
|
|
VkSurfaceKHR vk_surface;
|
|
|
|
VkSwapchainKHR swapchain;
|
|
|
|
bool need_new_swapchain;
|
|
|
|
} gfx_ctx_vulkan_data_t;
|
|
|
|
#endif
|
|
|
|
|
2014-10-24 07:23:10 +02:00
|
|
|
typedef struct gfx_ctx_wayland_data
|
|
|
|
{
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_EGL
|
2015-12-08 13:54:03 -03:00
|
|
|
egl_ctx_data_t egl;
|
2016-02-17 23:22:54 +01:00
|
|
|
struct wl_egl_window *win;
|
|
|
|
#endif
|
2015-12-08 13:54:03 -03:00
|
|
|
bool resize;
|
|
|
|
int fd;
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
struct wl_display *dpy;
|
|
|
|
struct wl_registry *registry;
|
|
|
|
struct wl_compositor *compositor;
|
|
|
|
struct wl_surface *surface;
|
|
|
|
struct wl_shell_surface *shell_surf;
|
|
|
|
struct wl_shell *shell;
|
|
|
|
struct wl_keyboard *wl_keyboard;
|
|
|
|
struct wl_pointer *wl_pointer;
|
2016-02-17 23:22:54 +01:00
|
|
|
unsigned swap_interval;
|
|
|
|
|
|
|
|
unsigned buffer_scale;
|
|
|
|
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-19 10:35:59 +01:00
|
|
|
gfx_ctx_vulkan_data_t vk;
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
2014-10-24 07:23:10 +02:00
|
|
|
} gfx_ctx_wayland_data_t;
|
|
|
|
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-17 23:22:54 +01:00
|
|
|
/* Forward declaration */
|
2016-02-19 10:35:59 +01:00
|
|
|
static bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
|
|
|
|
unsigned width, unsigned height, unsigned swap_interval);
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
|
|
|
|
2016-02-17 22:20:43 +01:00
|
|
|
static enum gfx_ctx_api wl_api;
|
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
#ifndef EGL_OPENGL_ES3_BIT_KHR
|
|
|
|
#define EGL_OPENGL_ES3_BIT_KHR 0x0040
|
|
|
|
#endif
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
static void sighandler(int sig)
|
|
|
|
{
|
|
|
|
(void)sig;
|
|
|
|
g_quit = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void install_sighandlers(void)
|
|
|
|
{
|
|
|
|
struct sigaction sa;
|
|
|
|
|
|
|
|
sa.sa_sigaction = NULL;
|
|
|
|
sa.sa_handler = sighandler;
|
|
|
|
sa.sa_flags = SA_RESTART;
|
|
|
|
sigemptyset(&sa.sa_mask);
|
|
|
|
sigaction(SIGINT, &sa, NULL);
|
|
|
|
sigaction(SIGTERM, &sa, NULL);
|
|
|
|
}
|
|
|
|
|
2014-10-27 14:35:23 +01:00
|
|
|
/* Shell surface callbacks. */
|
2014-10-24 07:23:10 +02:00
|
|
|
static void shell_surface_handle_ping(void *data,
|
|
|
|
struct wl_shell_surface *shell_surface,
|
2014-08-09 21:35:27 +02:00
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
wl_shell_surface_pong(shell_surface, serial);
|
|
|
|
}
|
|
|
|
|
2014-10-24 07:23:10 +02:00
|
|
|
static void shell_surface_handle_configure(void *data,
|
|
|
|
struct wl_shell_surface *shell_surface,
|
2014-08-09 21:35:27 +02:00
|
|
|
uint32_t edges, int32_t width, int32_t height)
|
|
|
|
{
|
2015-12-08 12:18:57 -03:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
(void)shell_surface;
|
|
|
|
(void)edges;
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
wl->width = wl->buffer_scale * width;
|
|
|
|
wl->height = wl->buffer_scale * height;
|
2014-10-24 07:23:10 +02:00
|
|
|
|
|
|
|
RARCH_LOG("[Wayland/EGL]: Surface configure: %u x %u.\n",
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->width, wl->height);
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
2014-10-24 07:23:10 +02:00
|
|
|
static void shell_surface_handle_popup_done(void *data,
|
|
|
|
struct wl_shell_surface *shell_surface)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
(void)shell_surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_shell_surface_listener shell_surface_listener = {
|
|
|
|
shell_surface_handle_ping,
|
|
|
|
shell_surface_handle_configure,
|
|
|
|
shell_surface_handle_popup_done,
|
|
|
|
};
|
|
|
|
|
2014-10-27 14:35:23 +01:00
|
|
|
/* Registry callbacks. */
|
2014-10-24 07:23:10 +02:00
|
|
|
static void registry_handle_global(void *data, struct wl_registry *reg,
|
|
|
|
uint32_t id, const char *interface, uint32_t version)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2015-12-08 12:18:57 -03:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
(void)version;
|
|
|
|
|
2016-01-20 06:16:55 +01:00
|
|
|
if (string_is_equal(interface, "wl_compositor"))
|
2016-02-18 05:31:24 +01:00
|
|
|
{
|
|
|
|
unsigned num = 1;
|
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
break;
|
|
|
|
case GFX_CTX_VULKAN_API:
|
|
|
|
num = 3;
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl->compositor = (struct wl_compositor*)wl_registry_bind(reg,
|
|
|
|
id, &wl_compositor_interface, num);
|
|
|
|
}
|
2016-01-20 06:16:55 +01:00
|
|
|
else if (string_is_equal(interface, "wl_shell"))
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->shell = (struct wl_shell*)wl_registry_bind(reg, id, &wl_shell_interface, 1);
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
2014-10-24 07:23:10 +02:00
|
|
|
static void registry_handle_global_remove(void *data,
|
|
|
|
struct wl_registry *registry, uint32_t id)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
(void)registry;
|
|
|
|
(void)id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_registry_listener registry_listener = {
|
|
|
|
registry_handle_global,
|
|
|
|
registry_handle_global_remove,
|
|
|
|
};
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
static void gfx_ctx_wl_get_video_size(void *data,
|
|
|
|
unsigned *width, unsigned *height);
|
|
|
|
|
2016-02-19 11:36:46 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
|
|
|
static void vulkan_destroy_context(gfx_ctx_vulkan_data_t *vk,
|
|
|
|
bool destroy_surface);
|
|
|
|
#endif
|
|
|
|
|
2014-10-24 07:23:10 +02:00
|
|
|
static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl)
|
|
|
|
{
|
|
|
|
if (!wl)
|
|
|
|
return;
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
egl_destroy(wl);
|
|
|
|
|
|
|
|
if (wl->win)
|
|
|
|
wl_egl_window_destroy(wl->win);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-19 11:36:46 +01:00
|
|
|
vulkan_destroy_context(&wl->vk, wl->surface);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
if (wl->fd >= 0)
|
|
|
|
close(wl->fd);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-12-08 13:54:03 -03:00
|
|
|
|
|
|
|
if (wl->shell)
|
|
|
|
wl_shell_destroy(wl->shell);
|
|
|
|
if (wl->compositor)
|
|
|
|
wl_compositor_destroy(wl->compositor);
|
|
|
|
if (wl->registry)
|
|
|
|
wl_registry_destroy(wl->registry);
|
|
|
|
if (wl->shell_surf)
|
|
|
|
wl_shell_surface_destroy(wl->shell_surf);
|
|
|
|
if (wl->surface)
|
|
|
|
wl_surface_destroy(wl->surface);
|
|
|
|
|
|
|
|
if (wl->dpy)
|
2014-10-24 07:23:10 +02:00
|
|
|
{
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_display_flush(wl->dpy);
|
|
|
|
wl_display_disconnect(wl->dpy);
|
2014-10-24 07:23:10 +02:00
|
|
|
}
|
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->win = NULL;
|
|
|
|
wl->shell = NULL;
|
|
|
|
wl->compositor = NULL;
|
|
|
|
wl->registry = NULL;
|
|
|
|
wl->dpy = NULL;
|
|
|
|
wl->shell_surf = NULL;
|
|
|
|
wl->surface = NULL;
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2016-02-19 11:36:46 +01:00
|
|
|
wl->width = 0;
|
|
|
|
wl->height = 0;
|
2014-10-24 07:23:10 +02:00
|
|
|
}
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2015-12-09 09:05:55 +01:00
|
|
|
static void flush_wayland_fd(gfx_ctx_wayland_data_t *wl)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
struct pollfd fd = {0};
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_display_dispatch_pending(wl->dpy);
|
|
|
|
wl_display_flush(wl->dpy);
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
fd.fd = wl->fd;
|
2014-08-09 21:35:27 +02:00
|
|
|
fd.events = POLLIN | POLLOUT | POLLERR | POLLHUP;
|
|
|
|
|
|
|
|
if (poll(&fd, 1, 0) > 0)
|
|
|
|
{
|
|
|
|
if (fd.revents & (POLLERR | POLLHUP))
|
|
|
|
{
|
2015-12-08 13:54:03 -03:00
|
|
|
close(wl->fd);
|
2016-02-17 23:22:54 +01:00
|
|
|
g_quit = true;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fd.revents & POLLIN)
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_display_dispatch(wl->dpy);
|
2014-08-09 21:35:27 +02:00
|
|
|
if (fd.revents & POLLOUT)
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_display_flush(wl->dpy);
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
static void gfx_ctx_wl_check_window(void *data, bool *quit,
|
2014-10-24 07:23:10 +02:00
|
|
|
bool *resize, unsigned *width, unsigned *height,
|
|
|
|
unsigned frame_count)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2016-02-17 23:22:54 +01:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2015-01-10 17:51:00 +01:00
|
|
|
unsigned new_width, new_height;
|
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
(void)frame_count;
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
flush_wayland_fd(wl);
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2015-01-10 17:51:00 +01:00
|
|
|
new_width = *width;
|
|
|
|
new_height = *height;
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
gfx_ctx_wl_get_video_size(data, &new_width, &new_height);
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-17 23:22:54 +01:00
|
|
|
/* Swapchains are recreated in set_resize as a
|
|
|
|
* central place, so use that to trigger swapchain reinit. */
|
2016-02-19 10:35:59 +01:00
|
|
|
*resize = wl->vk.need_new_swapchain;
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
if (new_width != *width || new_height != *height)
|
|
|
|
{
|
|
|
|
*resize = true;
|
|
|
|
*width = new_width;
|
|
|
|
*height = new_height;
|
|
|
|
}
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
*quit = g_quit;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
2016-01-07 00:58:33 +01:00
|
|
|
static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2015-12-08 12:18:57 -03:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
wl_egl_window_resize(wl->win, width, height, 0, 0);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-18 05:31:24 +01:00
|
|
|
wl->width = width;
|
2016-02-17 23:22:54 +01:00
|
|
|
wl->height = height;
|
2016-02-18 05:31:24 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
if (vulkan_create_swapchain(&wl->vk, width, height, wl->swap_interval))
|
|
|
|
wl->vk.context.invalid_swapchain = true;
|
2016-02-18 05:31:24 +01:00
|
|
|
else
|
2016-02-17 23:22:54 +01:00
|
|
|
{
|
|
|
|
RARCH_ERR("[Wayland/Vulkan]: Failed to update swapchain.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
wl->vk.need_new_swapchain = false;
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-01-07 00:58:33 +01:00
|
|
|
return true;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
static void gfx_ctx_wl_update_window_title(void *data)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2015-06-13 02:10:06 +02:00
|
|
|
char buf[128] = {0};
|
|
|
|
char buf_fps[128] = {0};
|
2015-03-20 22:08:36 +01:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-12-08 12:18:57 -03:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2015-01-10 17:51:00 +01:00
|
|
|
|
2015-03-07 23:03:56 +01:00
|
|
|
if (video_monitor_get_fps(buf, sizeof(buf),
|
|
|
|
buf_fps, sizeof(buf_fps)))
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_shell_surface_set_title(wl->shell_surf, buf);
|
2015-01-10 17:51:00 +01:00
|
|
|
|
2015-03-20 22:08:36 +01:00
|
|
|
if (settings->fps_show)
|
2015-12-07 15:32:14 +01:00
|
|
|
runloop_msg_queue_push(buf_fps, 1, 1, false);
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
static void gfx_ctx_wl_get_video_size(void *data,
|
|
|
|
unsigned *width, unsigned *height)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2015-12-08 12:18:57 -03:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
*width = wl->width;
|
|
|
|
*height = wl->height;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFAULT_WINDOWED_WIDTH 640
|
|
|
|
#define DEFAULT_WINDOWED_HEIGHT 480
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
#ifdef HAVE_EGL
|
2014-10-27 14:35:23 +01:00
|
|
|
#define WL_EGL_ATTRIBS_BASE \
|
2014-08-09 21:35:27 +02:00
|
|
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \
|
|
|
|
EGL_RED_SIZE, 1, \
|
|
|
|
EGL_GREEN_SIZE, 1, \
|
|
|
|
EGL_BLUE_SIZE, 1, \
|
|
|
|
EGL_ALPHA_SIZE, 0, \
|
|
|
|
EGL_DEPTH_SIZE, 0
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-19 11:04:51 +01:00
|
|
|
|
|
|
|
#define VK_GET_INSTANCE_PROC_ADDR(vk, inst, entrypoint) do { \
|
|
|
|
vk->fp##entrypoint = (PFN_vk##entrypoint) vkGetInstanceProcAddr(inst, "vk"#entrypoint); \
|
|
|
|
if (vk->fp##entrypoint == NULL) { \
|
|
|
|
RARCH_ERR("vkGetInstanceProcAddr failed to find vk%s\n", #entrypoint); \
|
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define VK_GET_DEVICE_PROC_ADDR(vk, dev, entrypoint) do { \
|
|
|
|
vk->fp##entrypoint = (PFN_vk##entrypoint) vkGetDeviceProcAddr(dev, "vk" #entrypoint); \
|
|
|
|
if (vk->fp##entrypoint == NULL) { \
|
|
|
|
RARCH_ERR("vkGetDeviceProcAddr failed to find vk%s\n", #entrypoint); \
|
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
2016-02-19 11:36:46 +01:00
|
|
|
static void vulkan_destroy_context(gfx_ctx_vulkan_data_t *vk, bool destroy_surface)
|
2016-02-19 11:12:43 +01:00
|
|
|
{
|
2016-02-19 11:36:46 +01:00
|
|
|
unsigned i;
|
|
|
|
if (vk->context.queue)
|
|
|
|
vkQueueWaitIdle(vk->context.queue);
|
|
|
|
if (vk->swapchain)
|
|
|
|
vk->fpDestroySwapchainKHR(vk->context.device,
|
|
|
|
vk->swapchain, NULL);
|
|
|
|
|
|
|
|
if (destroy_surface)
|
|
|
|
vk->fpDestroySurfaceKHR(vk->context.instance,
|
|
|
|
vk->vk_surface, NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < VULKAN_MAX_SWAPCHAIN_IMAGES; i++)
|
|
|
|
{
|
|
|
|
if (vk->context.swapchain_semaphores[i] != VK_NULL_HANDLE)
|
|
|
|
vkDestroySemaphore(vk->context.device,
|
|
|
|
vk->context.swapchain_semaphores[i], NULL);
|
|
|
|
if (vk->context.swapchain_fences[i] != VK_NULL_HANDLE)
|
|
|
|
vkDestroyFence(vk->context.device,
|
|
|
|
vk->context.swapchain_fences[i], NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL))
|
|
|
|
{
|
|
|
|
cached_device = vk->context.device;
|
|
|
|
cached_instance = vk->context.instance;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (vk->context.device)
|
|
|
|
vkDestroyDevice(vk->context.device, NULL);
|
|
|
|
if (vk->context.instance)
|
|
|
|
vkDestroyInstance(vk->context.instance, NULL);
|
|
|
|
}
|
2016-02-19 11:12:43 +01:00
|
|
|
}
|
|
|
|
|
2016-02-19 11:04:51 +01:00
|
|
|
static bool vulkan_init_context(gfx_ctx_vulkan_data_t *vk)
|
|
|
|
{
|
2016-02-17 23:22:54 +01:00
|
|
|
unsigned i;
|
|
|
|
uint32_t queue_count;
|
|
|
|
VkQueueFamilyProperties queue_properties[32];
|
2016-02-19 11:29:15 +01:00
|
|
|
VkInstanceCreateInfo info = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO };
|
|
|
|
VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO };
|
|
|
|
VkDeviceCreateInfo device_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
|
|
|
|
uint32_t gpu_count = 1;
|
|
|
|
bool found_queue = false;
|
|
|
|
static const float one = 1.0f;
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
static const char *instance_extensions[] = {
|
|
|
|
"VK_KHR_surface",
|
|
|
|
"VK_KHR_wayland_surface",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *device_extensions[] = {
|
|
|
|
"VK_KHR_swapchain",
|
|
|
|
};
|
2016-02-19 11:29:15 +01:00
|
|
|
VkApplicationInfo app = { VK_STRUCTURE_TYPE_APPLICATION_INFO };
|
2016-02-19 11:04:51 +01:00
|
|
|
VkPhysicalDeviceFeatures features = { false };
|
|
|
|
|
2016-02-19 11:29:15 +01:00
|
|
|
app.pApplicationName = "RetroArch";
|
|
|
|
app.applicationVersion = 0;
|
|
|
|
app.pEngineName = "RetroArch";
|
|
|
|
app.engineVersion = 0;
|
|
|
|
app.apiVersion = VK_API_VERSION;
|
2016-02-19 11:04:51 +01:00
|
|
|
|
2016-02-19 11:29:15 +01:00
|
|
|
info.pApplicationInfo = &app;
|
|
|
|
info.enabledExtensionCount = ARRAY_SIZE(instance_extensions);
|
|
|
|
info.ppEnabledExtensionNames = instance_extensions;
|
2016-02-19 11:04:51 +01:00
|
|
|
|
|
|
|
if (cached_instance)
|
|
|
|
{
|
2016-02-19 11:29:15 +01:00
|
|
|
vk->context.instance = cached_instance;
|
|
|
|
cached_instance = NULL;
|
2016-02-19 11:04:51 +01:00
|
|
|
}
|
|
|
|
else if (vkCreateInstance(&info, NULL, &vk->context.instance) != VK_SUCCESS)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (vkEnumeratePhysicalDevices(vk->context.instance,
|
|
|
|
&gpu_count, &vk->context.gpu) != VK_SUCCESS)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (gpu_count != 1)
|
|
|
|
{
|
|
|
|
RARCH_ERR("[Wayland/Vulkan]: Failed to enumerate Vulkan physical device.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-19 11:29:15 +01:00
|
|
|
vkGetPhysicalDeviceProperties(vk->context.gpu,
|
|
|
|
&vk->context.gpu_properties);
|
|
|
|
vkGetPhysicalDeviceMemoryProperties(vk->context.gpu,
|
|
|
|
&vk->context.memory_properties);
|
|
|
|
vkGetPhysicalDeviceQueueFamilyProperties(vk->context.gpu,
|
|
|
|
&queue_count, NULL);
|
|
|
|
|
2016-02-19 11:04:51 +01:00
|
|
|
if (queue_count < 1 || queue_count > 32)
|
|
|
|
return false;
|
2016-02-19 11:29:15 +01:00
|
|
|
|
|
|
|
vkGetPhysicalDeviceQueueFamilyProperties(vk->context.gpu,
|
|
|
|
&queue_count, queue_properties);
|
2016-02-19 11:04:51 +01:00
|
|
|
|
|
|
|
for (i = 0; i < queue_count; i++)
|
|
|
|
{
|
|
|
|
if (queue_properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
|
|
|
|
{
|
|
|
|
vk->context.graphics_queue_index = i;
|
|
|
|
RARCH_LOG("[Wayland/Vulkan]: Device supports %u sub-queues.\n",
|
|
|
|
queue_properties[i].queueCount);
|
|
|
|
found_queue = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found_queue)
|
|
|
|
{
|
|
|
|
RARCH_ERR("[Wayland/Vulkan]: Did not find suitable graphics queue.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
queue_info.queueFamilyIndex = vk->context.graphics_queue_index;
|
|
|
|
queue_info.queueCount = 1;
|
|
|
|
queue_info.pQueuePriorities = &one;
|
|
|
|
|
|
|
|
device_info.queueCreateInfoCount = 1;
|
|
|
|
device_info.pQueueCreateInfos = &queue_info;
|
|
|
|
device_info.enabledExtensionCount = ARRAY_SIZE(device_extensions);
|
|
|
|
device_info.ppEnabledExtensionNames = device_extensions;
|
|
|
|
device_info.pEnabledFeatures = &features;
|
|
|
|
|
|
|
|
if (cached_device)
|
|
|
|
{
|
|
|
|
vk->context.device = cached_device;
|
|
|
|
cached_device = NULL;
|
|
|
|
video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, NULL);
|
|
|
|
RARCH_LOG("[Vulkan]: Using cached Vulkan context.\n");
|
|
|
|
}
|
|
|
|
else if (vkCreateDevice(vk->context.gpu, &device_info,
|
|
|
|
NULL, &vk->context.device) != VK_SUCCESS)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
vkGetDeviceQueue(vk->context.device,
|
|
|
|
vk->context.graphics_queue_index, 0, &vk->context.queue);
|
|
|
|
|
|
|
|
VK_GET_INSTANCE_PROC_ADDR(vk,
|
|
|
|
vk->context.instance, GetPhysicalDeviceSurfaceSupportKHR);
|
|
|
|
VK_GET_INSTANCE_PROC_ADDR(vk,
|
|
|
|
vk->context.instance, GetPhysicalDeviceSurfaceCapabilitiesKHR);
|
|
|
|
VK_GET_INSTANCE_PROC_ADDR(vk,
|
|
|
|
vk->context.instance, GetPhysicalDeviceSurfaceFormatsKHR);
|
|
|
|
VK_GET_INSTANCE_PROC_ADDR(vk,
|
|
|
|
vk->context.instance, GetPhysicalDeviceSurfacePresentModesKHR);
|
|
|
|
VK_GET_INSTANCE_PROC_ADDR(vk,
|
|
|
|
vk->context.instance, CreateWaylandSurfaceKHR);
|
|
|
|
VK_GET_INSTANCE_PROC_ADDR(vk,
|
|
|
|
vk->context.instance, DestroySurfaceKHR);
|
|
|
|
VK_GET_DEVICE_PROC_ADDR(vk,
|
|
|
|
vk->context.device, CreateSwapchainKHR);
|
|
|
|
VK_GET_DEVICE_PROC_ADDR(vk,
|
|
|
|
vk->context.device, DestroySwapchainKHR);
|
|
|
|
VK_GET_DEVICE_PROC_ADDR(vk,
|
|
|
|
vk->context.device, GetSwapchainImagesKHR);
|
|
|
|
VK_GET_DEVICE_PROC_ADDR(vk,
|
|
|
|
vk->context.device, AcquireNextImageKHR);
|
|
|
|
VK_GET_DEVICE_PROC_ADDR(vk,
|
|
|
|
vk->context.device, QueuePresentKHR);
|
|
|
|
|
|
|
|
vk->context.queue_lock = slock_new();
|
|
|
|
if (!vk->context.queue_lock)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
|
|
|
|
2016-02-19 11:04:51 +01:00
|
|
|
static void *gfx_ctx_wl_init(void *video_driver)
|
|
|
|
{
|
|
|
|
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGL
|
2014-08-09 21:35:27 +02:00
|
|
|
static const EGLint egl_attribs_gl[] = {
|
2014-10-27 14:35:23 +01:00
|
|
|
WL_EGL_ATTRIBS_BASE,
|
2014-08-09 21:35:27 +02:00
|
|
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
|
|
EGL_NONE,
|
|
|
|
};
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGLES
|
|
|
|
#ifdef HAVE_OPENGLES2
|
2014-08-09 21:35:27 +02:00
|
|
|
static const EGLint egl_attribs_gles[] = {
|
2014-10-27 14:35:23 +01:00
|
|
|
WL_EGL_ATTRIBS_BASE,
|
2014-08-09 21:35:27 +02:00
|
|
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
|
|
EGL_NONE,
|
|
|
|
};
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGLES3
|
2014-08-09 21:35:27 +02:00
|
|
|
#ifdef EGL_KHR_create_context
|
|
|
|
static const EGLint egl_attribs_gles3[] = {
|
2014-10-27 14:35:23 +01:00
|
|
|
WL_EGL_ATTRIBS_BASE,
|
2014-08-09 21:35:27 +02:00
|
|
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
|
|
|
|
EGL_NONE,
|
|
|
|
};
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
#endif
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
#ifdef HAVE_EGL
|
2014-08-09 21:35:27 +02:00
|
|
|
static const EGLint egl_attribs_vg[] = {
|
2014-10-27 14:35:23 +01:00
|
|
|
WL_EGL_ATTRIBS_BASE,
|
2014-08-09 21:35:27 +02:00
|
|
|
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
|
|
|
EGL_NONE,
|
|
|
|
};
|
|
|
|
|
2015-11-19 18:10:59 +01:00
|
|
|
EGLint major = 0, minor = 0;
|
|
|
|
EGLint n;
|
2016-02-17 22:20:43 +01:00
|
|
|
const EGLint *attrib_ptr = NULL;
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
2014-10-24 07:23:10 +02:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)
|
|
|
|
calloc(1, sizeof(gfx_ctx_wayland_data_t));
|
|
|
|
|
|
|
|
if (!wl)
|
2015-12-08 12:18:57 -03:00
|
|
|
return NULL;
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
(void)video_driver;
|
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
switch (wl->egl.api)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGL
|
2014-08-09 21:35:27 +02:00
|
|
|
attrib_ptr = egl_attribs_gl;
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
break;
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGLES
|
|
|
|
#ifdef HAVE_OPENGLES3
|
2014-08-09 21:35:27 +02:00
|
|
|
#ifdef EGL_KHR_create_context
|
2015-12-08 13:54:03 -03:00
|
|
|
if (g_egl_major >= 3)
|
2014-08-09 21:35:27 +02:00
|
|
|
attrib_ptr = egl_attribs_gles3;
|
|
|
|
else
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
#endif
|
|
|
|
attrib_ptr = egl_attribs_gles;
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
break;
|
|
|
|
case GFX_CTX_OPENVG_API:
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_VG
|
2014-08-09 21:35:27 +02:00
|
|
|
attrib_ptr = egl_attribs_vg;
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
break;
|
2016-02-17 23:22:54 +01:00
|
|
|
case GFX_CTX_NONE:
|
2014-08-09 21:35:27 +02:00
|
|
|
default:
|
2016-02-17 22:20:43 +01:00
|
|
|
break;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
g_quit = 0;
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->dpy = wl_display_connect(NULL);
|
|
|
|
if (!wl->dpy)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
RARCH_ERR("Failed to connect to Wayland server.\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
install_sighandlers();
|
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->registry = wl_display_get_registry(wl->dpy);
|
|
|
|
wl_registry_add_listener(wl->registry, ®istry_listener, wl);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
wl_display_dispatch(wl->dpy);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_display_roundtrip(wl->dpy);
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
if (!wl->compositor)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
RARCH_ERR("Failed to create compositor.\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
if (!wl->shell)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
RARCH_ERR("Failed to create shell.\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->fd = wl_display_get_fd(wl->dpy);
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
switch (wl_api)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2016-02-17 23:22:54 +01:00
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
if (!egl_init_context(wl, (EGLNativeDisplayType)wl->dpy,
|
|
|
|
&major, &minor, &n, attrib_ptr))
|
|
|
|
{
|
|
|
|
egl_report_error();
|
|
|
|
goto error;
|
|
|
|
}
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
if (n == 0 || !egl_has_config(wl))
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-19 11:04:51 +01:00
|
|
|
if (!vulkan_init_context(&wl->vk))
|
|
|
|
goto error;
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2015-12-08 12:18:57 -03:00
|
|
|
return wl;
|
2014-08-09 21:35:27 +02:00
|
|
|
|
|
|
|
error:
|
2014-10-24 07:23:10 +02:00
|
|
|
gfx_ctx_wl_destroy_resources(wl);
|
|
|
|
|
|
|
|
if (wl)
|
|
|
|
free(wl);
|
|
|
|
|
2015-12-08 12:18:57 -03:00
|
|
|
return NULL;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
#ifdef HAVE_EGL
|
2015-12-08 13:54:03 -03:00
|
|
|
static EGLint *egl_fill_attribs(gfx_ctx_wayland_data_t *wl, EGLint *attr)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2015-12-08 13:54:03 -03:00
|
|
|
switch (wl->egl.api)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
#ifdef EGL_KHR_create_context
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
{
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGL
|
2015-12-08 13:54:03 -03:00
|
|
|
unsigned version = wl->egl.major * 1000 + wl->egl.minor;
|
2014-08-09 21:35:27 +02:00
|
|
|
bool core = version >= 3001;
|
|
|
|
#ifdef GL_DEBUG
|
|
|
|
bool debug = true;
|
|
|
|
#else
|
2015-05-20 19:56:12 +02:00
|
|
|
const struct retro_hw_render_callback *hw_render =
|
|
|
|
(const struct retro_hw_render_callback*)video_driver_callback();
|
|
|
|
bool debug = hw_render->debug_context;
|
2014-08-09 21:35:27 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (core)
|
|
|
|
{
|
|
|
|
*attr++ = EGL_CONTEXT_MAJOR_VERSION_KHR;
|
2015-12-08 13:54:03 -03:00
|
|
|
*attr++ = wl->egl.major;
|
2014-08-09 21:35:27 +02:00
|
|
|
*attr++ = EGL_CONTEXT_MINOR_VERSION_KHR;
|
2015-12-08 13:54:03 -03:00
|
|
|
*attr++ = wl->egl.minor;
|
2015-06-26 17:03:05 +02:00
|
|
|
/* Technically, we don't have core/compat until 3.2.
|
|
|
|
* Version 3.1 is either compat or not depending on GL_ARB_compatibility. */
|
2014-08-09 21:35:27 +02:00
|
|
|
if (version >= 3002)
|
|
|
|
{
|
|
|
|
*attr++ = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
|
|
|
*attr++ = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (debug)
|
|
|
|
{
|
|
|
|
*attr++ = EGL_CONTEXT_FLAGS_KHR;
|
|
|
|
*attr++ = EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
|
|
|
}
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGLES
|
2015-06-26 17:03:05 +02:00
|
|
|
*attr++ = EGL_CONTEXT_CLIENT_VERSION; /* Same as EGL_CONTEXT_MAJOR_VERSION */
|
2015-12-08 13:54:03 -03:00
|
|
|
*attr++ = wl->egl.major ? (EGLint)wl->egl.major : 2;
|
2014-08-09 21:35:27 +02:00
|
|
|
#ifdef EGL_KHR_create_context
|
2015-12-08 13:54:03 -03:00
|
|
|
if (wl->egl.minor > 0)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
*attr++ = EGL_CONTEXT_MINOR_VERSION_KHR;
|
2015-12-08 13:54:03 -03:00
|
|
|
*attr++ = wl->egl.minor;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
2016-02-17 22:20:43 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
case GFX_CTX_NONE:
|
2014-08-09 21:35:27 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*attr = EGL_NONE;
|
|
|
|
return attr;
|
|
|
|
}
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2014-10-24 07:23:10 +02:00
|
|
|
static void gfx_ctx_wl_destroy(void *data)
|
|
|
|
{
|
2015-12-08 12:18:57 -03:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2015-01-10 17:51:00 +01:00
|
|
|
|
2014-10-24 07:23:10 +02:00
|
|
|
if (!wl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gfx_ctx_wl_destroy_resources(wl);
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-19 11:36:46 +01:00
|
|
|
if (wl->vk.context.queue_lock)
|
|
|
|
slock_free(wl->vk.context.queue_lock);
|
2016-02-17 23:22:54 +01:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-12-08 12:18:57 -03:00
|
|
|
free(wl);
|
2014-10-24 07:23:10 +02:00
|
|
|
}
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
static void gfx_ctx_wl_set_swap_interval(void *data, unsigned swap_interval)
|
|
|
|
{
|
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
|
|
|
|
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
egl_set_swap_interval(data, swap_interval);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-17 23:22:54 +01:00
|
|
|
if (wl->swap_interval != swap_interval)
|
|
|
|
{
|
|
|
|
wl->swap_interval = swap_interval;
|
2016-02-19 10:35:59 +01:00
|
|
|
if (wl->vk.swapchain)
|
|
|
|
wl->vk.need_new_swapchain = true;
|
2016-02-17 23:22:54 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
static bool gfx_ctx_wl_set_video_mode(void *data,
|
2014-08-09 21:35:27 +02:00
|
|
|
unsigned width, unsigned height,
|
|
|
|
bool fullscreen)
|
|
|
|
{
|
2016-02-17 23:22:54 +01:00
|
|
|
#ifdef HAVE_EGL
|
2015-06-26 18:25:17 +02:00
|
|
|
EGLint egl_attribs[16];
|
2016-02-17 23:22:54 +01:00
|
|
|
EGLint *attr = egl_fill_attribs(
|
|
|
|
(gfx_ctx_wayland_data_t*)data, egl_attribs);
|
|
|
|
#endif
|
2015-12-08 12:18:57 -03:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2015-06-26 17:46:13 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
wl->width = width ? width : DEFAULT_WINDOWED_WIDTH;
|
|
|
|
wl->height = height ? height : DEFAULT_WINDOWED_HEIGHT;
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
/* TODO: Use wl_output::scale to obtain correct value. */
|
|
|
|
wl->buffer_scale = 1;
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
wl->surface = wl_compositor_create_surface(wl->compositor);
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
wl->win = wl_egl_window_create(wl->surface, wl->width, wl->height);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->shell_surf = wl_shell_get_shell_surface(wl->shell, wl->surface);
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-16 20:24:00 +01:00
|
|
|
wl_shell_surface_add_listener(wl->shell_surf, &shell_surface_listener, wl);
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_shell_surface_set_toplevel(wl->shell_surf);
|
|
|
|
wl_shell_surface_set_class(wl->shell_surf, "RetroArch");
|
|
|
|
wl_shell_surface_set_title(wl->shell_surf, "RetroArch");
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
switch (wl_api)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2016-02-17 23:22:54 +01:00
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
if (!egl_create_context(wl, (attr != egl_attribs) ? egl_attribs : NULL))
|
|
|
|
{
|
|
|
|
egl_report_error();
|
|
|
|
goto error;
|
|
|
|
}
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
if (!egl_create_surface(wl, (EGLNativeWindowType)wl->win))
|
|
|
|
goto error;
|
|
|
|
egl_set_swap_interval(wl, wl->egl.interval);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-08-09 21:35:27 +02:00
|
|
|
|
|
|
|
if (fullscreen)
|
2016-02-17 23:22:54 +01:00
|
|
|
wl_shell_surface_set_fullscreen(wl->shell_surf,
|
|
|
|
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL);
|
2014-08-09 21:35:27 +02:00
|
|
|
|
2015-12-09 09:05:55 +01:00
|
|
|
flush_wayland_fd(wl);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 11:50:25 +01:00
|
|
|
wl_display_roundtrip(wl->dpy);
|
|
|
|
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-17 23:22:54 +01:00
|
|
|
{
|
2016-02-19 11:50:25 +01:00
|
|
|
VkWaylandSurfaceCreateInfoKHR wl_info;
|
|
|
|
|
|
|
|
memset(&wl_info, 0, sizeof(VkWaylandSurfaceCreateInfoKHR));
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 11:50:25 +01:00
|
|
|
wl_info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
|
|
|
wl_info.pNext = NULL;
|
|
|
|
wl_info.flags = 0;
|
|
|
|
wl_info.display = (struct wl_display*)wl->dpy;
|
|
|
|
wl_info.surface = (struct wl_surface*)wl->surface;
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
wl->vk.fpCreateWaylandSurfaceKHR(wl->vk.context.instance,
|
|
|
|
&wl_info, NULL, &wl->vk.vk_surface);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
if (!vulkan_create_swapchain(
|
|
|
|
&wl->vk, wl->width, wl->height, wl->swap_interval))
|
2016-02-17 23:22:54 +01:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
error:
|
2014-10-08 18:09:01 +02:00
|
|
|
gfx_ctx_wl_destroy(data);
|
2014-08-09 21:35:27 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
static void gfx_ctx_wl_input_driver(void *data,
|
|
|
|
const input_driver_t **input, void **input_data)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
(void)data;
|
2015-06-26 17:03:05 +02:00
|
|
|
#if 0
|
2015-06-26 17:46:13 +02:00
|
|
|
void *wl = input_wayland.init();
|
|
|
|
*input = wl ? &input_wayland : NULL;
|
|
|
|
*input_data = wl;
|
2015-06-26 17:03:05 +02:00
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
*input = NULL;
|
|
|
|
*input_data = NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
static bool gfx_ctx_wl_has_focus(void *data)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-18 22:32:14 +01:00
|
|
|
static bool gfx_ctx_wl_suppress_screensaver(void *data, bool enable)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
(void)enable;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-08 18:09:01 +02:00
|
|
|
static bool gfx_ctx_wl_has_windowed(void *data)
|
2014-10-08 17:23:02 +02:00
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
static bool gfx_ctx_wl_bind_api(void *video_driver,
|
2014-10-08 18:09:01 +02:00
|
|
|
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
2014-08-09 21:35:27 +02:00
|
|
|
{
|
2015-12-08 13:54:03 -03:00
|
|
|
g_egl_major = major;
|
|
|
|
g_egl_minor = minor;
|
|
|
|
g_egl_api = api;
|
2015-01-10 17:51:00 +01:00
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
switch (api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGL
|
2014-08-09 21:35:27 +02:00
|
|
|
#ifndef EGL_KHR_create_context
|
|
|
|
if ((major * 1000 + minor) >= 3001)
|
|
|
|
return false;
|
|
|
|
#endif
|
2016-02-17 22:20:43 +01:00
|
|
|
wl_api = api;
|
2014-08-09 21:35:27 +02:00
|
|
|
return eglBindAPI(EGL_OPENGL_API);
|
2016-02-17 22:20:43 +01:00
|
|
|
#else
|
|
|
|
break;
|
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_OPENGLES
|
2014-08-09 21:35:27 +02:00
|
|
|
#ifndef EGL_KHR_create_context
|
|
|
|
if (major >= 3)
|
|
|
|
return false;
|
|
|
|
#endif
|
2016-02-17 22:20:43 +01:00
|
|
|
wl_api = api;
|
2014-08-09 21:35:27 +02:00
|
|
|
return eglBindAPI(EGL_OPENGL_ES_API);
|
2016-02-17 22:20:43 +01:00
|
|
|
#else
|
|
|
|
break;
|
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
case GFX_CTX_OPENVG_API:
|
2016-02-17 22:20:43 +01:00
|
|
|
#ifdef HAVE_VG
|
|
|
|
wl_api = api;
|
2014-08-09 21:35:27 +02:00
|
|
|
return eglBindAPI(EGL_OPENVG_API);
|
2016-02-17 22:20:43 +01:00
|
|
|
#else
|
|
|
|
break;
|
|
|
|
#endif
|
2016-02-17 23:22:54 +01:00
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-18 00:20:23 +01:00
|
|
|
wl_api = api;
|
2016-02-17 23:22:54 +01:00
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case GFX_CTX_NONE:
|
2014-08-09 21:35:27 +02:00
|
|
|
default:
|
2015-04-16 23:03:55 +02:00
|
|
|
break;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
2015-04-16 23:03:55 +02:00
|
|
|
|
|
|
|
return false;
|
2014-08-09 21:35:27 +02:00
|
|
|
}
|
|
|
|
|
2014-08-11 19:17:40 +02:00
|
|
|
static void keyboard_handle_keymap(void* data,
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
uint32_t format,
|
|
|
|
int fd,
|
|
|
|
uint32_t size)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void keyboard_handle_enter(void* data,
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface* surface,
|
|
|
|
struct wl_array* keys)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void keyboard_handle_leave(void* data,
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface* surface)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void keyboard_handle_key(void* data,
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t key,
|
|
|
|
uint32_t state)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void keyboard_handle_modifiers(void* data,
|
|
|
|
struct wl_keyboard* keyboard,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t modsDepressed,
|
|
|
|
uint32_t modsLatched,
|
|
|
|
uint32_t modsLocked,
|
|
|
|
uint32_t group)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_keyboard_listener keyboard_listener = {
|
|
|
|
keyboard_handle_keymap,
|
|
|
|
keyboard_handle_enter,
|
|
|
|
keyboard_handle_leave,
|
|
|
|
keyboard_handle_key,
|
|
|
|
keyboard_handle_modifiers,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void pointer_handle_enter(void* data,
|
|
|
|
struct wl_pointer* pointer,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface* surface,
|
|
|
|
wl_fixed_t sx,
|
|
|
|
wl_fixed_t sy)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pointer_handle_leave(void* data,
|
|
|
|
struct wl_pointer* pointer,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface* surface)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pointer_handle_motion(void* data,
|
|
|
|
struct wl_pointer* pointer,
|
|
|
|
uint32_t time,
|
|
|
|
wl_fixed_t sx,
|
|
|
|
wl_fixed_t sy)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pointer_handle_button(void* data,
|
|
|
|
struct wl_pointer* wl_pointer,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t button,
|
|
|
|
uint32_t state)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pointer_handle_axis(void* data,
|
|
|
|
struct wl_pointer* wl_pointer,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t axis,
|
|
|
|
wl_fixed_t value)
|
|
|
|
{
|
2015-06-26 17:03:05 +02:00
|
|
|
/* TODO */
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const struct wl_pointer_listener pointer_listener = {
|
|
|
|
pointer_handle_enter,
|
|
|
|
pointer_handle_leave,
|
|
|
|
pointer_handle_motion,
|
|
|
|
pointer_handle_button,
|
|
|
|
pointer_handle_axis,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void seat_handle_capabilities(void *data,
|
2014-09-06 22:14:09 -03:00
|
|
|
struct wl_seat *seat, unsigned caps)
|
2014-08-11 19:17:40 +02:00
|
|
|
{
|
2015-12-08 12:18:57 -03:00
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2014-10-24 07:23:10 +02:00
|
|
|
|
2015-12-08 13:54:03 -03:00
|
|
|
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !wl->wl_keyboard)
|
2014-08-11 19:17:40 +02:00
|
|
|
{
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->wl_keyboard = wl_seat_get_keyboard(seat);
|
|
|
|
wl_keyboard_add_listener(wl->wl_keyboard, &keyboard_listener, NULL);
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
2015-12-08 13:54:03 -03:00
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && wl->wl_keyboard)
|
2014-08-11 19:17:40 +02:00
|
|
|
{
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_keyboard_destroy(wl->wl_keyboard);
|
|
|
|
wl->wl_keyboard = NULL;
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
2015-12-08 13:54:03 -03:00
|
|
|
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !wl->wl_pointer)
|
2014-08-11 19:17:40 +02:00
|
|
|
{
|
2015-12-08 13:54:03 -03:00
|
|
|
wl->wl_pointer = wl_seat_get_pointer(seat);
|
|
|
|
wl_pointer_add_listener(wl->wl_pointer, &pointer_listener, NULL);
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
2015-12-08 13:54:03 -03:00
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && wl->wl_pointer)
|
2014-08-11 19:17:40 +02:00
|
|
|
{
|
2015-12-08 13:54:03 -03:00
|
|
|
wl_pointer_destroy(wl->wl_pointer);
|
|
|
|
wl->wl_pointer = NULL;
|
2014-08-11 19:17:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-07 18:06:50 +01:00
|
|
|
/* Seat callbacks - TODO/FIXME */
|
2014-08-11 19:17:40 +02:00
|
|
|
static const struct wl_seat_listener seat_listener = {
|
|
|
|
seat_handle_capabilities,
|
|
|
|
};
|
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-17 23:22:54 +01:00
|
|
|
static void *gfx_ctx_wl_get_context_data(void *data)
|
|
|
|
{
|
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
2016-02-19 10:35:59 +01:00
|
|
|
return &wl->vk.context;
|
2016-02-17 23:22:54 +01:00
|
|
|
}
|
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
static void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk)
|
2016-02-17 23:22:54 +01:00
|
|
|
{
|
2016-02-19 11:12:43 +01:00
|
|
|
unsigned index;
|
2016-02-17 23:22:54 +01:00
|
|
|
VkResult err;
|
|
|
|
VkFence fence;
|
|
|
|
VkFence *next_fence;
|
2016-02-19 11:12:43 +01:00
|
|
|
VkSemaphoreCreateInfo sem_info =
|
|
|
|
{ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO };
|
|
|
|
VkFenceCreateInfo info = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO };
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
vkCreateFence(vk->context.device, &info, NULL, &fence);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 11:12:43 +01:00
|
|
|
err = vk->fpAcquireNextImageKHR(vk->context.device,
|
|
|
|
vk->swapchain, UINT64_MAX,
|
2016-02-19 10:35:59 +01:00
|
|
|
VK_NULL_HANDLE, fence, &vk->context.current_swapchain_index);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
index = vk->context.current_swapchain_index;
|
|
|
|
if (vk->context.swapchain_semaphores[index] == VK_NULL_HANDLE)
|
2016-02-19 11:12:43 +01:00
|
|
|
vkCreateSemaphore(vk->context.device, &sem_info,
|
|
|
|
NULL, &vk->context.swapchain_semaphores[index]);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX);
|
|
|
|
vkDestroyFence(vk->context.device, fence, NULL);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
next_fence = &vk->context.swapchain_fences[index];
|
2016-02-17 23:22:54 +01:00
|
|
|
if (*next_fence != VK_NULL_HANDLE)
|
|
|
|
{
|
2016-02-19 10:35:59 +01:00
|
|
|
vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX);
|
|
|
|
vkResetFences(vk->context.device, 1, next_fence);
|
2016-02-17 23:22:54 +01:00
|
|
|
}
|
|
|
|
else
|
2016-02-19 10:35:59 +01:00
|
|
|
vkCreateFence(vk->context.device, &info, NULL, next_fence);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
if (err != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
RARCH_LOG("[Wayland/Vulkan]: AcquireNextImage failed, invalidating swapchain.\n");
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.invalid_swapchain = true;
|
2016-02-17 23:22:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-19 11:12:43 +01:00
|
|
|
static bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
|
|
|
|
unsigned width, unsigned height,
|
2016-02-19 10:35:59 +01:00
|
|
|
unsigned swap_interval)
|
2016-02-17 23:22:54 +01:00
|
|
|
{
|
2016-02-19 11:12:43 +01:00
|
|
|
unsigned i;
|
|
|
|
uint32_t format_count;
|
|
|
|
uint32_t desired_swapchain_images;
|
2016-02-17 23:22:54 +01:00
|
|
|
VkSurfaceCapabilitiesKHR surface_properties;
|
|
|
|
VkSurfaceFormatKHR formats[256];
|
|
|
|
VkSurfaceFormatKHR format;
|
|
|
|
VkExtent2D swapchain_size;
|
|
|
|
VkSwapchainKHR old_swapchain;
|
2016-02-19 11:12:43 +01:00
|
|
|
VkSurfaceTransformFlagBitsKHR pre_transform;
|
|
|
|
VkPresentModeKHR swapchain_present_mode = swap_interval
|
|
|
|
? VK_PRESENT_MODE_FIFO_KHR : VK_PRESENT_MODE_MAILBOX_KHR;
|
2016-02-17 23:22:54 +01:00
|
|
|
VkSwapchainCreateInfoKHR info = { VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR };
|
|
|
|
|
2016-02-19 11:12:43 +01:00
|
|
|
RARCH_LOG("[Wayland/Vulkan]: Creating swapchain with present mode: %u\n",
|
|
|
|
(unsigned)swapchain_present_mode);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 11:12:43 +01:00
|
|
|
vk->fpGetPhysicalDeviceSurfaceCapabilitiesKHR(vk->context.gpu,
|
|
|
|
vk->vk_surface, &surface_properties);
|
|
|
|
vk->fpGetPhysicalDeviceSurfaceFormatsKHR(vk->context.gpu,
|
|
|
|
vk->vk_surface, &format_count, NULL);
|
|
|
|
vk->fpGetPhysicalDeviceSurfaceFormatsKHR(vk->context.gpu,
|
|
|
|
vk->vk_surface, &format_count, formats);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
if (format_count == 1 && formats[0].format == VK_FORMAT_UNDEFINED)
|
|
|
|
{
|
|
|
|
format = formats[0];
|
|
|
|
format.format = VK_FORMAT_B8G8R8A8_UNORM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (format_count == 0)
|
|
|
|
{
|
|
|
|
RARCH_ERR("[Wayland Vulkan]: Surface has no formats.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
format = formats[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface_properties.currentExtent.width == -1)
|
|
|
|
{
|
2016-02-19 10:35:59 +01:00
|
|
|
swapchain_size.width = width;
|
|
|
|
swapchain_size.height = height;
|
2016-02-17 23:22:54 +01:00
|
|
|
}
|
|
|
|
else
|
2016-02-18 07:29:20 +01:00
|
|
|
swapchain_size = surface_properties.currentExtent;
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-18 07:29:20 +01:00
|
|
|
desired_swapchain_images = surface_properties.minImageCount + 1;
|
2016-02-19 11:12:43 +01:00
|
|
|
if ((surface_properties.maxImageCount > 0)
|
|
|
|
&& (desired_swapchain_images > surface_properties.maxImageCount))
|
2016-02-17 23:22:54 +01:00
|
|
|
desired_swapchain_images = surface_properties.maxImageCount;
|
|
|
|
|
2016-02-19 11:12:43 +01:00
|
|
|
if (surface_properties.supportedTransforms
|
|
|
|
& VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR)
|
2016-02-18 07:29:20 +01:00
|
|
|
pre_transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
2016-02-17 23:22:54 +01:00
|
|
|
else
|
2016-02-18 07:29:20 +01:00
|
|
|
pre_transform = surface_properties.currentTransform;
|
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
old_swapchain = vk->swapchain;
|
2016-02-18 07:29:20 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
info.surface = vk->vk_surface;
|
2016-02-18 07:29:20 +01:00
|
|
|
info.minImageCount = desired_swapchain_images;
|
|
|
|
info.imageFormat = format.format;
|
|
|
|
info.imageColorSpace = format.colorSpace;
|
|
|
|
info.imageExtent.width = swapchain_size.width;
|
|
|
|
info.imageExtent.height = swapchain_size.height;
|
|
|
|
info.imageArrayLayers = 1;
|
|
|
|
info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
|
|
|
| VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
|
|
|
info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
|
|
|
info.preTransform = pre_transform;
|
|
|
|
info.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
|
|
|
info.presentMode = swapchain_present_mode;
|
|
|
|
info.clipped = true;
|
|
|
|
info.oldSwapchain = old_swapchain;
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->fpCreateSwapchainKHR(vk->context.device, &info, NULL, &vk->swapchain);
|
2016-02-17 23:22:54 +01:00
|
|
|
if (old_swapchain != VK_NULL_HANDLE)
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->fpDestroySwapchainKHR(vk->context.device, old_swapchain, NULL);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.swapchain_width = swapchain_size.width;
|
|
|
|
vk->context.swapchain_height = swapchain_size.height;
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
/* Make sure we create a backbuffer format that is as we expect. */
|
|
|
|
switch (format.format)
|
|
|
|
{
|
|
|
|
case VK_FORMAT_B8G8R8A8_SRGB:
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.swapchain_format = VK_FORMAT_B8G8R8A8_UNORM;
|
|
|
|
vk->context.swapchain_is_srgb = true;
|
2016-02-17 23:22:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_FORMAT_R8G8B8A8_SRGB:
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.swapchain_format = VK_FORMAT_R8G8B8A8_UNORM;
|
|
|
|
vk->context.swapchain_is_srgb = true;
|
2016-02-17 23:22:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_FORMAT_R8G8B8_SRGB:
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.swapchain_format = VK_FORMAT_R8G8B8_UNORM;
|
|
|
|
vk->context.swapchain_is_srgb = true;
|
2016-02-17 23:22:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_FORMAT_B8G8R8_SRGB:
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.swapchain_format = VK_FORMAT_B8G8R8_UNORM;
|
|
|
|
vk->context.swapchain_is_srgb = true;
|
2016-02-17 23:22:54 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.swapchain_format = format.format;
|
2016-02-17 23:22:54 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->fpGetSwapchainImagesKHR(vk->context.device, vk->swapchain,
|
|
|
|
&vk->context.num_swapchain_images, NULL);
|
|
|
|
vk->fpGetSwapchainImagesKHR(vk->context.device, vk->swapchain,
|
|
|
|
&vk->context.num_swapchain_images, vk->context.swapchain_images);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
for (i = 0; i < vk->context.num_swapchain_images; i++)
|
2016-02-17 23:22:54 +01:00
|
|
|
{
|
2016-02-19 10:35:59 +01:00
|
|
|
if (vk->context.swapchain_fences[i])
|
2016-02-17 23:22:54 +01:00
|
|
|
{
|
2016-02-19 11:12:43 +01:00
|
|
|
vkDestroyFence(vk->context.device,
|
|
|
|
vk->context.swapchain_fences[i], NULL);
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.swapchain_fences[i] = VK_NULL_HANDLE;
|
2016-02-17 23:22:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
vulkan_acquire_next_image(vk);
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-19 10:35:59 +01:00
|
|
|
static void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index)
|
2016-02-17 23:22:54 +01:00
|
|
|
{
|
2016-02-19 11:12:43 +01:00
|
|
|
VkResult result = VK_SUCCESS;
|
|
|
|
VkResult err = VK_SUCCESS;
|
|
|
|
VkPresentInfoKHR present = { VK_STRUCTURE_TYPE_PRESENT_INFO_KHR };
|
|
|
|
present.swapchainCount = 1;
|
|
|
|
present.pSwapchains = &vk->swapchain;
|
|
|
|
present.pImageIndices = &index;
|
|
|
|
present.pResults = &result;
|
2016-02-17 23:22:54 +01:00
|
|
|
present.waitSemaphoreCount = 1;
|
2016-02-19 11:12:43 +01:00
|
|
|
present.pWaitSemaphores = &vk->context.swapchain_semaphores[index];
|
2016-02-17 23:22:54 +01:00
|
|
|
|
|
|
|
/* Better hope QueuePresent doesn't block D: */
|
2016-02-19 10:35:59 +01:00
|
|
|
slock_lock(vk->context.queue_lock);
|
|
|
|
err = vk->fpQueuePresentKHR(vk->context.queue, &present);
|
2016-02-19 11:12:43 +01:00
|
|
|
|
2016-02-17 23:22:54 +01:00
|
|
|
if (err != VK_SUCCESS || result != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
RARCH_LOG("[Wayland/Vulkan]: QueuePresent failed, invalidating swapchain.\n");
|
2016-02-19 10:35:59 +01:00
|
|
|
vk->context.invalid_swapchain = true;
|
2016-02-17 23:22:54 +01:00
|
|
|
}
|
2016-02-19 10:35:59 +01:00
|
|
|
slock_unlock(vk->context.queue_lock);
|
2016-02-17 23:22:54 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void gfx_ctx_wl_swap_buffers(void *data)
|
|
|
|
{
|
|
|
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
|
|
|
|
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
egl_swap_buffers(data);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_VULKAN_API:
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-19 10:35:59 +01:00
|
|
|
vulkan_present(&wl->vk, wl->vk.context.current_swapchain_index);
|
|
|
|
vulkan_acquire_next_image(&wl->vk);
|
2016-02-17 23:22:54 +01:00
|
|
|
flush_wayland_fd(wl);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gfx_ctx_proc_t gfx_ctx_wl_get_proc_address(const char *symbol)
|
|
|
|
{
|
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
return egl_get_proc_address(symbol);
|
2016-02-19 11:12:43 +01:00
|
|
|
#else
|
2016-02-17 23:22:54 +01:00
|
|
|
break;
|
2016-02-19 11:12:43 +01:00
|
|
|
#endif
|
2016-02-17 23:22:54 +01:00
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gfx_ctx_wl_bind_hw_render(void *data, bool enable)
|
|
|
|
{
|
|
|
|
switch (wl_api)
|
|
|
|
{
|
|
|
|
case GFX_CTX_OPENGL_API:
|
|
|
|
case GFX_CTX_OPENGL_ES_API:
|
|
|
|
case GFX_CTX_OPENVG_API:
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
egl_bind_hw_render(data, enable);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case GFX_CTX_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-09 21:35:27 +02:00
|
|
|
const gfx_ctx_driver_t gfx_ctx_wayland = {
|
2014-10-08 18:09:01 +02:00
|
|
|
gfx_ctx_wl_init,
|
|
|
|
gfx_ctx_wl_destroy,
|
|
|
|
gfx_ctx_wl_bind_api,
|
2016-02-17 23:22:54 +01:00
|
|
|
gfx_ctx_wl_set_swap_interval,
|
2014-10-08 18:09:01 +02:00
|
|
|
gfx_ctx_wl_set_video_mode,
|
|
|
|
gfx_ctx_wl_get_video_size,
|
2015-02-24 21:36:23 +01:00
|
|
|
NULL, /* get_video_output_size */
|
|
|
|
NULL, /* get_video_output_prev */
|
|
|
|
NULL, /* get_video_output_next */
|
2015-04-08 20:10:30 +02:00
|
|
|
NULL, /* get_metrics */
|
2015-02-24 19:58:14 +01:00
|
|
|
NULL,
|
2014-10-08 18:09:01 +02:00
|
|
|
gfx_ctx_wl_update_window_title,
|
|
|
|
gfx_ctx_wl_check_window,
|
|
|
|
gfx_ctx_wl_set_resize,
|
|
|
|
gfx_ctx_wl_has_focus,
|
2015-01-18 22:32:14 +01:00
|
|
|
gfx_ctx_wl_suppress_screensaver,
|
2014-10-08 18:09:01 +02:00
|
|
|
gfx_ctx_wl_has_windowed,
|
2016-02-17 23:22:54 +01:00
|
|
|
gfx_ctx_wl_swap_buffers,
|
2014-10-08 18:09:01 +02:00
|
|
|
gfx_ctx_wl_input_driver,
|
2016-02-17 23:22:54 +01:00
|
|
|
gfx_ctx_wl_get_proc_address,
|
2014-08-09 21:35:27 +02:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
"wayland",
|
2016-02-17 23:22:54 +01:00
|
|
|
gfx_ctx_wl_bind_hw_render,
|
2016-02-19 07:58:14 +01:00
|
|
|
#ifdef HAVE_VULKAN
|
2016-02-17 23:22:54 +01:00
|
|
|
gfx_ctx_wl_get_context_data
|
|
|
|
#else
|
|
|
|
NULL
|
|
|
|
#endif
|
2014-08-09 21:35:27 +02:00
|
|
|
};
|