gl-x11-egl.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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)(
  28. EGLenum platform, void *native_display, 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,
  74. xcb_drawable_t drawable)
  75. {
  76. xcb_get_geometry_cookie_t cookie;
  77. xcb_generic_error_t *error;
  78. xcb_get_geometry_reply_t *reply;
  79. cookie = xcb_get_geometry(xcb_conn, drawable);
  80. reply = xcb_get_geometry_reply(xcb_conn, cookie, &error);
  81. if (error) {
  82. blog(LOG_ERROR, "Failed to fetch parent window geometry!");
  83. free(error);
  84. free(reply);
  85. return 0;
  86. }
  87. return reply;
  88. }
  89. static const char *get_egl_error_string2(const EGLint error)
  90. {
  91. switch (error) {
  92. #define OBS_EGL_CASE_ERROR(e) \
  93. case e: \
  94. return #e;
  95. OBS_EGL_CASE_ERROR(EGL_SUCCESS)
  96. OBS_EGL_CASE_ERROR(EGL_NOT_INITIALIZED)
  97. OBS_EGL_CASE_ERROR(EGL_BAD_ACCESS)
  98. OBS_EGL_CASE_ERROR(EGL_BAD_ALLOC)
  99. OBS_EGL_CASE_ERROR(EGL_BAD_ATTRIBUTE)
  100. OBS_EGL_CASE_ERROR(EGL_BAD_CONTEXT)
  101. OBS_EGL_CASE_ERROR(EGL_BAD_CONFIG)
  102. OBS_EGL_CASE_ERROR(EGL_BAD_CURRENT_SURFACE)
  103. OBS_EGL_CASE_ERROR(EGL_BAD_DISPLAY)
  104. OBS_EGL_CASE_ERROR(EGL_BAD_SURFACE)
  105. OBS_EGL_CASE_ERROR(EGL_BAD_MATCH)
  106. OBS_EGL_CASE_ERROR(EGL_BAD_PARAMETER)
  107. OBS_EGL_CASE_ERROR(EGL_BAD_NATIVE_PIXMAP)
  108. OBS_EGL_CASE_ERROR(EGL_BAD_NATIVE_WINDOW)
  109. OBS_EGL_CASE_ERROR(EGL_CONTEXT_LOST)
  110. #undef OBS_EGL_CASE_ERROR
  111. default:
  112. return "Unknown";
  113. }
  114. }
  115. static const char *get_egl_error_string()
  116. {
  117. return get_egl_error_string2(eglGetError());
  118. }
  119. static EGLDisplay get_egl_display(struct gl_platform *plat)
  120. {
  121. Display *display = plat->xdisplay;
  122. EGLDisplay edisplay = EGL_NO_DISPLAY;
  123. const char *egl_client_extensions = NULL;
  124. egl_client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
  125. PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
  126. (PFNEGLGETPLATFORMDISPLAYEXTPROC)(strstr(egl_client_extensions,
  127. "EGL_EXT_platform_base")
  128. ? eglGetProcAddress(
  129. "eglGetPlatformDisplayEXT")
  130. : NULL);
  131. if (eglGetPlatformDisplayEXT) {
  132. const EGLint plat_attribs[] = {EGL_NONE};
  133. edisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_X11_EXT,
  134. display, plat_attribs);
  135. if (EGL_NO_DISPLAY == edisplay)
  136. blog(LOG_ERROR, "Failed to get EGL/X11 display");
  137. }
  138. if (EGL_NO_DISPLAY == edisplay)
  139. edisplay = eglGetDisplay(display);
  140. return edisplay;
  141. }
  142. static bool gl_context_create(struct gl_platform *plat)
  143. {
  144. Display *display = plat->xdisplay;
  145. int frame_buf_config_count = 0;
  146. EGLDisplay edisplay = EGL_NO_DISPLAY;
  147. EGLConfig config = NULL;
  148. EGLContext context = EGL_NO_CONTEXT;
  149. int egl_min = 0, egl_maj = 0;
  150. bool success = false;
  151. eglBindAPI(EGL_OPENGL_API);
  152. edisplay = get_egl_display(plat);
  153. if (EGL_NO_DISPLAY == edisplay) {
  154. blog(LOG_ERROR,
  155. "Failed to get EGL display using eglGetDisplay");
  156. return false;
  157. }
  158. if (!eglInitialize(edisplay, &egl_maj, &egl_min)) {
  159. blog(LOG_ERROR, "Failed to initialize EGL: %s",
  160. get_egl_error_string());
  161. return false;
  162. }
  163. if (!eglChooseConfig(edisplay, ctx_config_attribs, &config, 1,
  164. &frame_buf_config_count)) {
  165. blog(LOG_ERROR, "Unable to find suitable EGL config: %s",
  166. get_egl_error_string());
  167. goto error;
  168. }
  169. context =
  170. eglCreateContext(edisplay, config, EGL_NO_CONTEXT, ctx_attribs);
  171. #ifdef _DEBUG
  172. if (EGL_NO_CONTEXT == context) {
  173. const EGLint error = eglGetError();
  174. if (error == EGL_BAD_ATTRIBUTE) {
  175. /* Sometimes creation fails because debug gl is not supported */
  176. blog(LOG_ERROR,
  177. "Unable to create EGL context with DEBUG attrib, trying without");
  178. context = eglCreateContext(edisplay, config,
  179. EGL_NO_CONTEXT,
  180. ctx_attribs + 2);
  181. } else {
  182. blog(LOG_ERROR, "Unable to create EGL context: %s",
  183. get_egl_error_string2(error));
  184. goto error;
  185. }
  186. }
  187. #endif
  188. if (EGL_NO_CONTEXT == context) {
  189. blog(LOG_ERROR, "Unable to create EGL context: %s",
  190. get_egl_error_string());
  191. goto error;
  192. }
  193. plat->pbuffer =
  194. eglCreatePbufferSurface(edisplay, config, ctx_pbuffer_attribs);
  195. if (EGL_NO_SURFACE == plat->pbuffer) {
  196. blog(LOG_ERROR, "Failed to create OpenGL pbuffer: %s",
  197. get_egl_error_string());
  198. goto error;
  199. }
  200. plat->edisplay = edisplay;
  201. plat->config = config;
  202. plat->context = context;
  203. success = true;
  204. blog(LOG_DEBUG, "Created EGLDisplay %p", plat->edisplay);
  205. error:
  206. if (!success) {
  207. if (EGL_NO_CONTEXT != context)
  208. eglDestroyContext(edisplay, context);
  209. eglTerminate(edisplay);
  210. }
  211. XSync(display, false);
  212. return success;
  213. }
  214. static void gl_context_destroy(struct gl_platform *plat)
  215. {
  216. eglMakeCurrent(plat->edisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
  217. EGL_NO_CONTEXT);
  218. eglDestroyContext(plat->edisplay, plat->context);
  219. }
  220. static struct gl_windowinfo *
  221. gl_x11_egl_windowinfo_create(const struct gs_init_data *info)
  222. {
  223. UNUSED_PARAMETER(info);
  224. return bmalloc(sizeof(struct gl_windowinfo));
  225. }
  226. static void gl_x11_egl_windowinfo_destroy(struct gl_windowinfo *info)
  227. {
  228. bfree(info);
  229. }
  230. static Display *open_windowless_display(bool *should_close)
  231. {
  232. Display *platform_display = obs_get_nix_platform_display();
  233. Display *display;
  234. xcb_connection_t *xcb_conn;
  235. if (platform_display) {
  236. display = platform_display;
  237. *should_close = false;
  238. } else {
  239. display = XOpenDisplay(NULL);
  240. *should_close = true;
  241. }
  242. if (!display) {
  243. blog(LOG_ERROR, "Unable to open new X connection!");
  244. return NULL;
  245. }
  246. xcb_conn = XGetXCBConnection(display);
  247. if (!xcb_conn) {
  248. blog(LOG_ERROR, "Unable to get XCB connection to main display");
  249. goto error;
  250. }
  251. if (!gladLoadEGL()) {
  252. blog(LOG_ERROR, "Unable to load EGL entry functions.");
  253. goto error;
  254. }
  255. return display;
  256. error:
  257. if (*should_close)
  258. XCloseDisplay(display);
  259. return NULL;
  260. }
  261. static int x_error_handler(Display *display, XErrorEvent *error)
  262. {
  263. char str1[512];
  264. char str2[512];
  265. char str3[512];
  266. XGetErrorText(display, error->error_code, str1, sizeof(str1));
  267. XGetErrorText(display, error->request_code, str2, sizeof(str2));
  268. XGetErrorText(display, error->minor_code, str3, sizeof(str3));
  269. blog(LOG_ERROR,
  270. "X Error: %s, Major opcode: %s, "
  271. "Minor opcode: %s, Serial: %lu",
  272. str1, str2, str3, error->serial);
  273. return 0;
  274. }
  275. static struct gl_platform *gl_x11_egl_platform_create(gs_device_t *device,
  276. uint32_t adapter)
  277. {
  278. /* There's some trickery here... we're mixing libX11, xcb, and EGL
  279. For an explanation see here: http://xcb.freedesktop.org/MixingCalls/
  280. Essentially, EGL requires Xlib. Everything else we use xcb. */
  281. struct gl_platform *plat = bmalloc(sizeof(struct gl_platform));
  282. Display *display = open_windowless_display(&plat->close_xdisplay);
  283. if (!display) {
  284. goto fail_display_open;
  285. }
  286. XSetEventQueueOwner(display, XCBOwnsEventQueue);
  287. XSetErrorHandler(x_error_handler);
  288. /* We assume later that cur_swap is already set. */
  289. device->plat = plat;
  290. plat->xdisplay = display;
  291. if (!gl_context_create(plat)) {
  292. blog(LOG_ERROR, "Failed to create context!");
  293. goto fail_context_create;
  294. }
  295. if (!eglMakeCurrent(plat->edisplay, plat->pbuffer, plat->pbuffer,
  296. plat->context)) {
  297. blog(LOG_ERROR, "Failed to make context current: %s",
  298. get_egl_error_string());
  299. goto fail_make_current;
  300. }
  301. if (!gladLoadGL()) {
  302. blog(LOG_ERROR, "Failed to load OpenGL entry functions.");
  303. goto fail_load_gl;
  304. }
  305. goto success;
  306. fail_make_current:
  307. gl_context_destroy(plat);
  308. fail_context_create:
  309. fail_load_gl:
  310. if (plat->close_xdisplay)
  311. XCloseDisplay(plat->xdisplay);
  312. fail_display_open:
  313. bfree(plat);
  314. plat = NULL;
  315. success:
  316. UNUSED_PARAMETER(adapter);
  317. return plat;
  318. }
  319. static void gl_x11_egl_platform_destroy(struct gl_platform *plat)
  320. {
  321. if (!plat)
  322. return;
  323. gl_context_destroy(plat);
  324. eglTerminate(plat->edisplay);
  325. if (plat->close_xdisplay)
  326. XCloseDisplay(plat->xdisplay);
  327. bfree(plat);
  328. }
  329. static bool gl_x11_egl_platform_init_swapchain(struct gs_swap_chain *swap)
  330. {
  331. const struct gl_platform *plat = swap->device->plat;
  332. Display *display = plat->xdisplay;
  333. xcb_connection_t *xcb_conn = XGetXCBConnection(display);
  334. xcb_window_t wid = xcb_generate_id(xcb_conn);
  335. xcb_window_t parent = swap->info.window.id;
  336. xcb_get_geometry_reply_t *geometry =
  337. get_window_geometry(xcb_conn, parent);
  338. bool status = false;
  339. int visual;
  340. if (!geometry)
  341. goto fail_geometry_request;
  342. {
  343. if (!eglGetConfigAttrib(plat->edisplay, plat->config,
  344. EGL_NATIVE_VISUAL_ID,
  345. (EGLint *)&visual)) {
  346. blog(LOG_ERROR,
  347. "Cannot get visual id for EGL context: %s",
  348. get_egl_error_string());
  349. goto fail_visual_id;
  350. }
  351. }
  352. xcb_colormap_t colormap = xcb_generate_id(xcb_conn);
  353. uint32_t mask = XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP;
  354. uint32_t mask_values[] = {0, colormap, 0};
  355. xcb_create_colormap(xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap, parent,
  356. visual);
  357. xcb_void_cookie_t window_cookie = xcb_create_window_checked(
  358. xcb_conn, 24 /* Hardcoded? */, wid, parent, 0, 0,
  359. geometry->width, geometry->height, 0, 0, visual, mask,
  360. mask_values);
  361. xcb_generic_error_t *err = xcb_request_check(xcb_conn, window_cookie);
  362. if (err != NULL) {
  363. char text[512];
  364. XGetErrorText(display, err->error_code, text, sizeof(text));
  365. blog(LOG_ERROR,
  366. "Swapchain window creation failed: %s"
  367. ", Major opcode: %d, Minor opcode: %d",
  368. text, err->major_code, err->minor_code);
  369. goto fail_window_surface;
  370. }
  371. const EGLSurface surface =
  372. eglCreateWindowSurface(plat->edisplay, plat->config, wid, 0);
  373. if (EGL_NO_SURFACE == surface) {
  374. blog(LOG_ERROR, "Cannot get window EGL surface: %s",
  375. get_egl_error_string());
  376. goto fail_window_surface;
  377. }
  378. swap->wi->window = wid;
  379. swap->wi->surface = surface;
  380. xcb_map_window(xcb_conn, wid);
  381. status = true;
  382. goto success;
  383. fail_window_surface:
  384. fail_visual_id:
  385. fail_geometry_request:
  386. success:
  387. free(geometry);
  388. return status;
  389. }
  390. static void gl_x11_egl_platform_cleanup_swapchain(struct gs_swap_chain *swap)
  391. {
  392. UNUSED_PARAMETER(swap);
  393. /* Really nothing to clean up? */
  394. }
  395. static void gl_x11_egl_device_enter_context(gs_device_t *device)
  396. {
  397. const EGLContext context = device->plat->context;
  398. const EGLDisplay display = device->plat->edisplay;
  399. const EGLSurface surface = (device->cur_swap)
  400. ? device->cur_swap->wi->surface
  401. : device->plat->pbuffer;
  402. if (!eglMakeCurrent(display, surface, surface, context))
  403. blog(LOG_ERROR, "Failed to make context current: %s",
  404. get_egl_error_string());
  405. }
  406. static void gl_x11_egl_device_leave_context(gs_device_t *device)
  407. {
  408. const EGLDisplay display = device->plat->edisplay;
  409. if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
  410. EGL_NO_CONTEXT)) {
  411. blog(LOG_ERROR, "Failed to reset current context: %s",
  412. get_egl_error_string());
  413. }
  414. }
  415. static void *gl_x11_egl_device_get_device_obj(gs_device_t *device)
  416. {
  417. return device->plat->context;
  418. }
  419. static void gl_x11_egl_getclientsize(const struct gs_swap_chain *swap,
  420. uint32_t *width, uint32_t *height)
  421. {
  422. xcb_connection_t *xcb_conn =
  423. XGetXCBConnection(swap->device->plat->xdisplay);
  424. xcb_window_t window = swap->wi->window;
  425. xcb_get_geometry_reply_t *geometry =
  426. get_window_geometry(xcb_conn, window);
  427. if (geometry) {
  428. *width = geometry->width;
  429. *height = geometry->height;
  430. }
  431. free(geometry);
  432. }
  433. static void gl_x11_egl_update(gs_device_t *device)
  434. {
  435. Display *display = device->plat->xdisplay;
  436. xcb_window_t window = device->cur_swap->wi->window;
  437. uint32_t values[] = {device->cur_swap->info.cx,
  438. device->cur_swap->info.cy};
  439. xcb_configure_window(XGetXCBConnection(display), window,
  440. XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
  441. values);
  442. }
  443. static void gl_x11_egl_clear_context(gs_device_t *device)
  444. {
  445. Display *display = device->plat->edisplay;
  446. if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
  447. EGL_NO_CONTEXT)) {
  448. blog(LOG_ERROR, "Failed to reset current context.");
  449. }
  450. }
  451. static void gl_x11_egl_device_load_swapchain(gs_device_t *device,
  452. gs_swapchain_t *swap)
  453. {
  454. if (device->cur_swap == swap)
  455. return;
  456. device->cur_swap = swap;
  457. device_enter_context(device);
  458. }
  459. static void gl_x11_egl_device_present(gs_device_t *device)
  460. {
  461. Display *display = device->plat->xdisplay;
  462. xcb_connection_t *xcb_conn = XGetXCBConnection(display);
  463. xcb_generic_event_t *xcb_event;
  464. while ((xcb_event = xcb_poll_for_event(xcb_conn))) {
  465. free(xcb_event);
  466. }
  467. if (eglSwapInterval(device->plat->edisplay, 0) == EGL_FALSE) {
  468. blog(LOG_ERROR, "eglSwapInterval failed");
  469. }
  470. if (!eglSwapBuffers(device->plat->edisplay,
  471. device->cur_swap->wi->surface))
  472. blog(LOG_ERROR, "Cannot swap EGL buffers: %s",
  473. get_egl_error_string());
  474. }
  475. static struct gs_texture *gl_x11_egl_device_texture_create_from_dmabuf(
  476. gs_device_t *device, unsigned int width, unsigned int height,
  477. uint32_t drm_format, enum gs_color_format color_format,
  478. uint32_t n_planes, const int *fds, const uint32_t *strides,
  479. const uint32_t *offsets, const uint64_t *modifiers)
  480. {
  481. struct gl_platform *plat = device->plat;
  482. return gl_egl_create_dmabuf_image(plat->edisplay, width, height,
  483. drm_format, color_format, n_planes,
  484. fds, strides, offsets, modifiers);
  485. }
  486. static struct gs_texture *gl_x11_egl_device_texture_create_from_pixmap(
  487. gs_device_t *device, uint32_t width, uint32_t height,
  488. enum gs_color_format color_format, uint32_t target, void *pixmap)
  489. {
  490. struct gl_platform *plat = device->plat;
  491. return gl_egl_create_texture_from_pixmap(plat->edisplay, width, height,
  492. color_format, target,
  493. (EGLClientBuffer)pixmap);
  494. }
  495. static bool gl_x11_egl_device_query_dmabuf_capabilities(
  496. gs_device_t *device, enum gs_dmabuf_flags *dmabuf_flags,
  497. uint32_t **drm_formats, size_t *n_formats)
  498. {
  499. struct gl_platform *plat = device->plat;
  500. return gl_egl_query_dmabuf_capabilities(plat->edisplay, dmabuf_flags,
  501. drm_formats, n_formats);
  502. }
  503. static bool gl_x11_egl_device_query_dmabuf_modifiers_for_format(
  504. gs_device_t *device, uint32_t drm_format, uint64_t **modifiers,
  505. size_t *n_modifiers)
  506. {
  507. struct gl_platform *plat = device->plat;
  508. return gl_egl_query_dmabuf_modifiers_for_format(
  509. plat->edisplay, drm_format, modifiers, n_modifiers);
  510. }
  511. static bool gl_x11_egl_enum_adapters(gs_device_t *device,
  512. bool (*callback)(void *param,
  513. const char *name,
  514. uint32_t id),
  515. void *param)
  516. {
  517. return gl_egl_enum_adapters(device->plat->edisplay, callback, param);
  518. }
  519. static const struct gl_winsys_vtable egl_x11_winsys_vtable = {
  520. .windowinfo_create = gl_x11_egl_windowinfo_create,
  521. .windowinfo_destroy = gl_x11_egl_windowinfo_destroy,
  522. .platform_create = gl_x11_egl_platform_create,
  523. .platform_destroy = gl_x11_egl_platform_destroy,
  524. .platform_init_swapchain = gl_x11_egl_platform_init_swapchain,
  525. .platform_cleanup_swapchain = gl_x11_egl_platform_cleanup_swapchain,
  526. .device_enter_context = gl_x11_egl_device_enter_context,
  527. .device_leave_context = gl_x11_egl_device_leave_context,
  528. .device_get_device_obj = gl_x11_egl_device_get_device_obj,
  529. .getclientsize = gl_x11_egl_getclientsize,
  530. .clear_context = gl_x11_egl_clear_context,
  531. .update = gl_x11_egl_update,
  532. .device_load_swapchain = gl_x11_egl_device_load_swapchain,
  533. .device_present = gl_x11_egl_device_present,
  534. .device_texture_create_from_dmabuf =
  535. gl_x11_egl_device_texture_create_from_dmabuf,
  536. .device_query_dmabuf_capabilities =
  537. gl_x11_egl_device_query_dmabuf_capabilities,
  538. .device_query_dmabuf_modifiers_for_format =
  539. gl_x11_egl_device_query_dmabuf_modifiers_for_format,
  540. .device_texture_create_from_pixmap =
  541. gl_x11_egl_device_texture_create_from_pixmap,
  542. .device_enum_adapters = gl_x11_egl_enum_adapters,
  543. };
  544. const struct gl_winsys_vtable *gl_x11_egl_get_winsys_vtable(void)
  545. {
  546. return &egl_x11_winsys_vtable;
  547. }