gl-x11-egl.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. /******************************************************************************
  2. Copyright (C) 2019 by Ivan Avdeev <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. /* GL context initialization using EGL instead of GLX
  15. * Which is essential for improved and more performant screen grabbing and
  16. * VA-API feeding techniques.
  17. *
  18. * Note: most of x11-related functionality was taken from gl-x11.c
  19. */
  20. #include <X11/Xlib.h>
  21. #include <X11/Xlib-xcb.h>
  22. #include <xcb/xcb.h>
  23. #include <stdio.h>
  24. #include "gl-egl-common.h"
  25. #include "gl-x11-egl.h"
  26. #include <glad/glad_egl.h>
  27. typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform, void *native_display,
  28. const EGLint *attrib_list);
  29. static const int ctx_attribs[] = {
  30. #ifdef _DEBUG
  31. EGL_CONTEXT_OPENGL_DEBUG,
  32. EGL_TRUE,
  33. #endif
  34. EGL_CONTEXT_OPENGL_PROFILE_MASK,
  35. EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
  36. EGL_CONTEXT_MAJOR_VERSION,
  37. 3,
  38. EGL_CONTEXT_MINOR_VERSION,
  39. 3,
  40. EGL_NONE,
  41. };
  42. static int ctx_pbuffer_attribs[] = {EGL_WIDTH, 2, EGL_HEIGHT, 2, EGL_NONE};
  43. static const EGLint ctx_config_attribs[] = {EGL_STENCIL_SIZE,
  44. 0,
  45. EGL_DEPTH_SIZE,
  46. 0,
  47. EGL_BUFFER_SIZE,
  48. 24,
  49. EGL_ALPHA_SIZE,
  50. 0,
  51. EGL_RENDERABLE_TYPE,
  52. EGL_OPENGL_BIT,
  53. EGL_SURFACE_TYPE,
  54. EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
  55. EGL_NONE};
  56. struct gl_windowinfo {
  57. /* Windows in X11 are defined with integers (XID).
  58. * xcb_window_t is a define for this... they are
  59. * compatible with Xlib as well.
  60. */
  61. xcb_window_t window;
  62. EGLSurface surface;
  63. };
  64. struct gl_platform {
  65. Display *xdisplay;
  66. EGLDisplay edisplay;
  67. EGLConfig config;
  68. EGLContext context;
  69. EGLSurface pbuffer;
  70. bool close_xdisplay;
  71. };
  72. /* The following utility function is copied verbatim from GLX code. */
  73. static xcb_get_geometry_reply_t *get_window_geometry(xcb_connection_t *xcb_conn, xcb_drawable_t drawable)
  74. {
  75. xcb_get_geometry_cookie_t cookie;
  76. xcb_generic_error_t *error;
  77. xcb_get_geometry_reply_t *reply;
  78. cookie = xcb_get_geometry(xcb_conn, drawable);
  79. reply = xcb_get_geometry_reply(xcb_conn, cookie, &error);
  80. if (error) {
  81. blog(LOG_ERROR, "Failed to fetch parent window geometry!");
  82. free(error);
  83. free(reply);
  84. return 0;
  85. }
  86. return reply;
  87. }
  88. static const char *get_egl_error_string2(const EGLint error)
  89. {
  90. switch (error) {
  91. #define OBS_EGL_CASE_ERROR(e) \
  92. case e: \
  93. return #e;
  94. OBS_EGL_CASE_ERROR(EGL_SUCCESS)
  95. OBS_EGL_CASE_ERROR(EGL_NOT_INITIALIZED)
  96. OBS_EGL_CASE_ERROR(EGL_BAD_ACCESS)
  97. OBS_EGL_CASE_ERROR(EGL_BAD_ALLOC)
  98. OBS_EGL_CASE_ERROR(EGL_BAD_ATTRIBUTE)
  99. OBS_EGL_CASE_ERROR(EGL_BAD_CONTEXT)
  100. OBS_EGL_CASE_ERROR(EGL_BAD_CONFIG)
  101. OBS_EGL_CASE_ERROR(EGL_BAD_CURRENT_SURFACE)
  102. OBS_EGL_CASE_ERROR(EGL_BAD_DISPLAY)
  103. OBS_EGL_CASE_ERROR(EGL_BAD_SURFACE)
  104. OBS_EGL_CASE_ERROR(EGL_BAD_MATCH)
  105. OBS_EGL_CASE_ERROR(EGL_BAD_PARAMETER)
  106. OBS_EGL_CASE_ERROR(EGL_BAD_NATIVE_PIXMAP)
  107. OBS_EGL_CASE_ERROR(EGL_BAD_NATIVE_WINDOW)
  108. OBS_EGL_CASE_ERROR(EGL_CONTEXT_LOST)
  109. #undef OBS_EGL_CASE_ERROR
  110. default:
  111. return "Unknown";
  112. }
  113. }
  114. static const char *get_egl_error_string()
  115. {
  116. return get_egl_error_string2(eglGetError());
  117. }
  118. static EGLDisplay get_egl_display(struct gl_platform *plat)
  119. {
  120. Display *display = plat->xdisplay;
  121. EGLDisplay edisplay = EGL_NO_DISPLAY;
  122. const char *egl_client_extensions = NULL;
  123. egl_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
  124. PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
  125. (PFNEGLGETPLATFORMDISPLAYEXTPROC)(strstr(egl_client_extensions, "EGL_EXT_platform_base")
  126. ? eglGetProcAddress("eglGetPlatformDisplayEXT")
  127. : NULL);
  128. if (eglGetPlatformDisplayEXT) {
  129. const EGLint plat_attribs[] = {EGL_NONE};
  130. edisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_X11_EXT, display, plat_attribs);
  131. if (EGL_NO_DISPLAY == edisplay)
  132. blog(LOG_ERROR, "Failed to get EGL/X11 display");
  133. }
  134. if (EGL_NO_DISPLAY == edisplay)
  135. edisplay = eglGetDisplay(display);
  136. return edisplay;
  137. }
  138. static bool gl_context_create(struct gl_platform *plat)
  139. {
  140. Display *display = plat->xdisplay;
  141. int frame_buf_config_count = 0;
  142. EGLDisplay edisplay = EGL_NO_DISPLAY;
  143. EGLConfig config = NULL;
  144. EGLContext context = EGL_NO_CONTEXT;
  145. int egl_min = 0, egl_maj = 0;
  146. bool success = false;
  147. eglBindAPI(EGL_OPENGL_API);
  148. edisplay = get_egl_display(plat);
  149. if (EGL_NO_DISPLAY == edisplay) {
  150. blog(LOG_ERROR, "Failed to get EGL display using eglGetDisplay");
  151. return false;
  152. }
  153. if (!eglInitialize(edisplay, &egl_maj, &egl_min)) {
  154. blog(LOG_ERROR, "Failed to initialize EGL: %s", get_egl_error_string());
  155. return false;
  156. }
  157. if (!eglChooseConfig(edisplay, ctx_config_attribs, &config, 1, &frame_buf_config_count)) {
  158. blog(LOG_ERROR, "Unable to find suitable EGL config: %s", get_egl_error_string());
  159. goto error;
  160. }
  161. context = eglCreateContext(edisplay, config, EGL_NO_CONTEXT, ctx_attribs);
  162. #ifdef _DEBUG
  163. if (EGL_NO_CONTEXT == context) {
  164. const EGLint error = eglGetError();
  165. if (error == EGL_BAD_ATTRIBUTE) {
  166. /* Sometimes creation fails because debug gl is not supported */
  167. blog(LOG_ERROR, "Unable to create EGL context with DEBUG attrib, trying without");
  168. context = eglCreateContext(edisplay, config, EGL_NO_CONTEXT, ctx_attribs + 2);
  169. } else {
  170. blog(LOG_ERROR, "Unable to create EGL context: %s", get_egl_error_string2(error));
  171. goto error;
  172. }
  173. }
  174. #endif
  175. if (EGL_NO_CONTEXT == context) {
  176. blog(LOG_ERROR, "Unable to create EGL context: %s", get_egl_error_string());
  177. goto error;
  178. }
  179. plat->pbuffer = eglCreatePbufferSurface(edisplay, config, ctx_pbuffer_attribs);
  180. if (EGL_NO_SURFACE == plat->pbuffer) {
  181. blog(LOG_ERROR, "Failed to create OpenGL pbuffer: %s", get_egl_error_string());
  182. goto error;
  183. }
  184. plat->edisplay = edisplay;
  185. plat->config = config;
  186. plat->context = context;
  187. success = true;
  188. blog(LOG_DEBUG, "Created EGLDisplay %p", plat->edisplay);
  189. error:
  190. if (!success) {
  191. if (EGL_NO_CONTEXT != context)
  192. eglDestroyContext(edisplay, context);
  193. eglTerminate(edisplay);
  194. }
  195. XSync(display, false);
  196. return success;
  197. }
  198. static void gl_context_destroy(struct gl_platform *plat)
  199. {
  200. eglMakeCurrent(plat->edisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
  201. eglDestroyContext(plat->edisplay, plat->context);
  202. }
  203. static struct gl_windowinfo *gl_x11_egl_windowinfo_create(const struct gs_init_data *info)
  204. {
  205. UNUSED_PARAMETER(info);
  206. return bmalloc(sizeof(struct gl_windowinfo));
  207. }
  208. static void gl_x11_egl_windowinfo_destroy(struct gl_windowinfo *info)
  209. {
  210. bfree(info);
  211. }
  212. static Display *open_windowless_display(bool *should_close)
  213. {
  214. Display *platform_display = obs_get_nix_platform_display();
  215. Display *display;
  216. xcb_connection_t *xcb_conn;
  217. if (platform_display) {
  218. display = platform_display;
  219. *should_close = false;
  220. } else {
  221. display = XOpenDisplay(NULL);
  222. *should_close = true;
  223. }
  224. if (!display) {
  225. blog(LOG_ERROR, "Unable to open new X connection!");
  226. return NULL;
  227. }
  228. xcb_conn = XGetXCBConnection(display);
  229. if (!xcb_conn) {
  230. blog(LOG_ERROR, "Unable to get XCB connection to main display");
  231. goto error;
  232. }
  233. if (!gladLoadEGL()) {
  234. blog(LOG_ERROR, "Unable to load EGL entry functions.");
  235. goto error;
  236. }
  237. return display;
  238. error:
  239. if (*should_close)
  240. XCloseDisplay(display);
  241. return NULL;
  242. }
  243. static int x_error_handler(Display *display, XErrorEvent *error)
  244. {
  245. char str1[512];
  246. char str2[512];
  247. char str3[512];
  248. XGetErrorText(display, error->error_code, str1, sizeof(str1));
  249. XGetErrorText(display, error->request_code, str2, sizeof(str2));
  250. XGetErrorText(display, error->minor_code, str3, sizeof(str3));
  251. blog(LOG_ERROR,
  252. "X Error: %s, Major opcode: %s, "
  253. "Minor opcode: %s, Serial: %lu",
  254. str1, str2, str3, error->serial);
  255. return 0;
  256. }
  257. static struct gl_platform *gl_x11_egl_platform_create(gs_device_t *device, uint32_t adapter)
  258. {
  259. /* There's some trickery here... we're mixing libX11, xcb, and EGL
  260. For an explanation see here: http://xcb.freedesktop.org/MixingCalls/
  261. Essentially, EGL requires Xlib. Everything else we use xcb. */
  262. struct gl_platform *plat = bmalloc(sizeof(struct gl_platform));
  263. Display *display = open_windowless_display(&plat->close_xdisplay);
  264. if (!display) {
  265. goto fail_display_open;
  266. }
  267. XSetEventQueueOwner(display, XCBOwnsEventQueue);
  268. XSetErrorHandler(x_error_handler);
  269. /* We assume later that cur_swap is already set. */
  270. device->plat = plat;
  271. plat->xdisplay = display;
  272. if (!gl_context_create(plat)) {
  273. blog(LOG_ERROR, "Failed to create context!");
  274. goto fail_context_create;
  275. }
  276. if (!eglMakeCurrent(plat->edisplay, plat->pbuffer, plat->pbuffer, plat->context)) {
  277. blog(LOG_ERROR, "Failed to make context current: %s", get_egl_error_string());
  278. goto fail_make_current;
  279. }
  280. if (!gladLoadGL()) {
  281. blog(LOG_ERROR, "Failed to load OpenGL entry functions.");
  282. goto fail_load_gl;
  283. }
  284. goto success;
  285. fail_make_current:
  286. gl_context_destroy(plat);
  287. fail_context_create:
  288. fail_load_gl:
  289. if (plat->close_xdisplay)
  290. XCloseDisplay(plat->xdisplay);
  291. fail_display_open:
  292. bfree(plat);
  293. plat = NULL;
  294. success:
  295. UNUSED_PARAMETER(adapter);
  296. return plat;
  297. }
  298. static void gl_x11_egl_platform_destroy(struct gl_platform *plat)
  299. {
  300. if (!plat)
  301. return;
  302. gl_context_destroy(plat);
  303. eglTerminate(plat->edisplay);
  304. if (plat->close_xdisplay)
  305. XCloseDisplay(plat->xdisplay);
  306. bfree(plat);
  307. }
  308. static bool gl_x11_egl_platform_init_swapchain(struct gs_swap_chain *swap)
  309. {
  310. const struct gl_platform *plat = swap->device->plat;
  311. Display *display = plat->xdisplay;
  312. xcb_connection_t *xcb_conn = XGetXCBConnection(display);
  313. xcb_window_t wid = xcb_generate_id(xcb_conn);
  314. xcb_window_t parent = swap->info.window.id;
  315. xcb_get_geometry_reply_t *geometry = get_window_geometry(xcb_conn, parent);
  316. bool status = false;
  317. int visual;
  318. if (!geometry)
  319. goto fail_geometry_request;
  320. {
  321. if (!eglGetConfigAttrib(plat->edisplay, plat->config, EGL_NATIVE_VISUAL_ID, (EGLint *)&visual)) {
  322. blog(LOG_ERROR, "Cannot get visual id for EGL context: %s", get_egl_error_string());
  323. goto fail_visual_id;
  324. }
  325. }
  326. xcb_colormap_t colormap = xcb_generate_id(xcb_conn);
  327. uint32_t mask = XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP;
  328. uint32_t mask_values[] = {0, colormap, 0};
  329. xcb_create_colormap(xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap, parent, visual);
  330. xcb_void_cookie_t window_cookie = xcb_create_window_checked(xcb_conn, 24 /* Hardcoded? */, wid, parent, 0, 0,
  331. geometry->width, geometry->height, 0, 0, visual,
  332. mask, mask_values);
  333. xcb_generic_error_t *err = xcb_request_check(xcb_conn, window_cookie);
  334. if (err != NULL) {
  335. char text[512];
  336. XGetErrorText(display, err->error_code, text, sizeof(text));
  337. blog(LOG_ERROR,
  338. "Swapchain window creation failed: %s"
  339. ", Major opcode: %d, Minor opcode: %d",
  340. text, err->major_code, err->minor_code);
  341. goto fail_window_surface;
  342. }
  343. const EGLSurface surface = eglCreateWindowSurface(plat->edisplay, plat->config, wid, 0);
  344. if (EGL_NO_SURFACE == surface) {
  345. blog(LOG_ERROR, "Cannot get window EGL surface: %s", get_egl_error_string());
  346. goto fail_window_surface;
  347. }
  348. swap->wi->window = wid;
  349. swap->wi->surface = surface;
  350. xcb_map_window(xcb_conn, wid);
  351. status = true;
  352. goto success;
  353. fail_window_surface:
  354. fail_visual_id:
  355. fail_geometry_request:
  356. success:
  357. free(geometry);
  358. return status;
  359. }
  360. static void gl_x11_egl_platform_cleanup_swapchain(struct gs_swap_chain *swap)
  361. {
  362. UNUSED_PARAMETER(swap);
  363. /* Really nothing to clean up? */
  364. }
  365. static void gl_x11_egl_device_enter_context(gs_device_t *device)
  366. {
  367. const EGLContext context = device->plat->context;
  368. const EGLDisplay display = device->plat->edisplay;
  369. const EGLSurface surface = (device->cur_swap) ? device->cur_swap->wi->surface : device->plat->pbuffer;
  370. if (!eglMakeCurrent(display, surface, surface, context))
  371. blog(LOG_ERROR, "Failed to make context current: %s", get_egl_error_string());
  372. }
  373. static void gl_x11_egl_device_leave_context(gs_device_t *device)
  374. {
  375. const EGLDisplay display = device->plat->edisplay;
  376. if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
  377. blog(LOG_ERROR, "Failed to reset current context: %s", get_egl_error_string());
  378. }
  379. }
  380. static void *gl_x11_egl_device_get_device_obj(gs_device_t *device)
  381. {
  382. return device->plat->context;
  383. }
  384. static void gl_x11_egl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width, uint32_t *height)
  385. {
  386. xcb_connection_t *xcb_conn = XGetXCBConnection(swap->device->plat->xdisplay);
  387. xcb_window_t window = swap->wi->window;
  388. xcb_get_geometry_reply_t *geometry = get_window_geometry(xcb_conn, window);
  389. if (geometry) {
  390. *width = geometry->width;
  391. *height = geometry->height;
  392. }
  393. free(geometry);
  394. }
  395. static void gl_x11_egl_update(gs_device_t *device)
  396. {
  397. Display *display = device->plat->xdisplay;
  398. xcb_window_t window = device->cur_swap->wi->window;
  399. uint32_t values[] = {device->cur_swap->info.cx, device->cur_swap->info.cy};
  400. xcb_configure_window(XGetXCBConnection(display), window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
  401. values);
  402. }
  403. static void gl_x11_egl_clear_context(gs_device_t *device)
  404. {
  405. Display *display = device->plat->edisplay;
  406. if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
  407. blog(LOG_ERROR, "Failed to reset current context.");
  408. }
  409. }
  410. static void gl_x11_egl_device_load_swapchain(gs_device_t *device, gs_swapchain_t *swap)
  411. {
  412. if (device->cur_swap == swap)
  413. return;
  414. device->cur_swap = swap;
  415. device_enter_context(device);
  416. }
  417. static void gl_x11_egl_device_present(gs_device_t *device)
  418. {
  419. Display *display = device->plat->xdisplay;
  420. xcb_connection_t *xcb_conn = XGetXCBConnection(display);
  421. xcb_generic_event_t *xcb_event;
  422. while ((xcb_event = xcb_poll_for_event(xcb_conn))) {
  423. free(xcb_event);
  424. }
  425. if (eglSwapInterval(device->plat->edisplay, 0) == EGL_FALSE) {
  426. blog(LOG_ERROR, "eglSwapInterval failed");
  427. }
  428. if (!eglSwapBuffers(device->plat->edisplay, device->cur_swap->wi->surface))
  429. blog(LOG_ERROR, "Cannot swap EGL buffers: %s", get_egl_error_string());
  430. }
  431. static struct gs_texture *gl_x11_egl_device_texture_create_from_dmabuf(gs_device_t *device, unsigned int width,
  432. unsigned int height, uint32_t drm_format,
  433. enum gs_color_format color_format,
  434. uint32_t n_planes, const int *fds,
  435. const uint32_t *strides, const uint32_t *offsets,
  436. const uint64_t *modifiers)
  437. {
  438. struct gl_platform *plat = device->plat;
  439. return gl_egl_create_dmabuf_image(plat->edisplay, width, height, drm_format, color_format, n_planes, fds,
  440. strides, offsets, modifiers);
  441. }
  442. static struct gs_texture *gl_x11_egl_device_texture_create_from_pixmap(gs_device_t *device, uint32_t width,
  443. uint32_t height,
  444. enum gs_color_format color_format,
  445. uint32_t target, void *pixmap)
  446. {
  447. struct gl_platform *plat = device->plat;
  448. return gl_egl_create_texture_from_pixmap(plat->edisplay, width, height, color_format, target,
  449. (EGLClientBuffer)pixmap);
  450. }
  451. static bool gl_x11_egl_device_query_dmabuf_capabilities(gs_device_t *device, enum gs_dmabuf_flags *dmabuf_flags,
  452. uint32_t **drm_formats, size_t *n_formats)
  453. {
  454. struct gl_platform *plat = device->plat;
  455. return gl_egl_query_dmabuf_capabilities(plat->edisplay, dmabuf_flags, drm_formats, n_formats);
  456. }
  457. static bool gl_x11_egl_device_query_dmabuf_modifiers_for_format(gs_device_t *device, uint32_t drm_format,
  458. uint64_t **modifiers, size_t *n_modifiers)
  459. {
  460. struct gl_platform *plat = device->plat;
  461. return gl_egl_query_dmabuf_modifiers_for_format(plat->edisplay, drm_format, modifiers, n_modifiers);
  462. }
  463. static bool gl_x11_egl_enum_adapters(gs_device_t *device, bool (*callback)(void *param, const char *name, uint32_t id),
  464. void *param)
  465. {
  466. return gl_egl_enum_adapters(device->plat->edisplay, callback, param);
  467. }
  468. static const struct gl_winsys_vtable egl_x11_winsys_vtable = {
  469. .windowinfo_create = gl_x11_egl_windowinfo_create,
  470. .windowinfo_destroy = gl_x11_egl_windowinfo_destroy,
  471. .platform_create = gl_x11_egl_platform_create,
  472. .platform_destroy = gl_x11_egl_platform_destroy,
  473. .platform_init_swapchain = gl_x11_egl_platform_init_swapchain,
  474. .platform_cleanup_swapchain = gl_x11_egl_platform_cleanup_swapchain,
  475. .device_enter_context = gl_x11_egl_device_enter_context,
  476. .device_leave_context = gl_x11_egl_device_leave_context,
  477. .device_get_device_obj = gl_x11_egl_device_get_device_obj,
  478. .getclientsize = gl_x11_egl_getclientsize,
  479. .clear_context = gl_x11_egl_clear_context,
  480. .update = gl_x11_egl_update,
  481. .device_load_swapchain = gl_x11_egl_device_load_swapchain,
  482. .device_present = gl_x11_egl_device_present,
  483. .device_texture_create_from_dmabuf = gl_x11_egl_device_texture_create_from_dmabuf,
  484. .device_query_dmabuf_capabilities = gl_x11_egl_device_query_dmabuf_capabilities,
  485. .device_query_dmabuf_modifiers_for_format = gl_x11_egl_device_query_dmabuf_modifiers_for_format,
  486. .device_texture_create_from_pixmap = gl_x11_egl_device_texture_create_from_pixmap,
  487. .device_enum_adapters = gl_x11_egl_enum_adapters,
  488. };
  489. const struct gl_winsys_vtable *gl_x11_egl_get_winsys_vtable(void)
  490. {
  491. return &egl_x11_winsys_vtable;
  492. }