2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Kristian Høgsberg <krh@bitplanet.net>
38 #include <GL/internal/dri_interface.h>
41 #include <xcb/xfixes.h>
42 #include <X11/Xlib-xcb.h>
44 #include <glapi/glapi.h>
45 #include "eglconfig.h"
46 #include "eglcontext.h"
47 #include "egldisplay.h"
48 #include "egldriver.h"
49 #include "eglcurrent.h"
51 #include "eglsurface.h"
54 struct dri2_egl_driver
59 struct dri2_egl_display
61 xcb_connection_t
*conn
;
64 __DRIscreen
*dri_screen
;
66 __DRIcoreExtension
*core
;
67 __DRIdri2Extension
*dri2
;
68 __DRI2flushExtension
*flush
;
69 __DRItexBufferExtension
*tex_buffer
;
70 __DRIimageExtension
*image
;
73 __DRIdri2LoaderExtension loader_extension
;
74 __DRIimageLookupExtension image_lookup_extension
;
75 const __DRIextension
*extensions
[3];
78 struct dri2_egl_context
81 __DRIcontext
*dri_context
;
84 struct dri2_egl_surface
87 __DRIdrawable
*dri_drawable
;
88 xcb_drawable_t drawable
;
89 __DRIbuffer buffers
[5];
91 xcb_xfixes_region_t region
;
96 struct dri2_egl_config
99 const __DRIconfig
*dri_config
;
102 struct dri2_egl_image
105 __DRIimage
*dri_image
;
108 /* standard typecasts */
109 _EGL_DRIVER_STANDARD_TYPECASTS(dri2_egl
)
110 _EGL_DRIVER_TYPECAST(dri2_egl_image
, _EGLImage
, obj
)
112 EGLint dri2_to_egl_attribute_map
[] = {
114 EGL_BUFFER_SIZE
, /* __DRI_ATTRIB_BUFFER_SIZE */
115 EGL_LEVEL
, /* __DRI_ATTRIB_LEVEL */
116 EGL_RED_SIZE
, /* __DRI_ATTRIB_RED_SIZE */
117 EGL_GREEN_SIZE
, /* __DRI_ATTRIB_GREEN_SIZE */
118 EGL_BLUE_SIZE
, /* __DRI_ATTRIB_BLUE_SIZE */
119 EGL_LUMINANCE_SIZE
, /* __DRI_ATTRIB_LUMINANCE_SIZE */
120 EGL_ALPHA_SIZE
, /* __DRI_ATTRIB_ALPHA_SIZE */
121 0, /* __DRI_ATTRIB_ALPHA_MASK_SIZE */
122 EGL_DEPTH_SIZE
, /* __DRI_ATTRIB_DEPTH_SIZE */
123 EGL_STENCIL_SIZE
, /* __DRI_ATTRIB_STENCIL_SIZE */
124 0, /* __DRI_ATTRIB_ACCUM_RED_SIZE */
125 0, /* __DRI_ATTRIB_ACCUM_GREEN_SIZE */
126 0, /* __DRI_ATTRIB_ACCUM_BLUE_SIZE */
127 0, /* __DRI_ATTRIB_ACCUM_ALPHA_SIZE */
128 EGL_SAMPLE_BUFFERS
, /* __DRI_ATTRIB_SAMPLE_BUFFERS */
129 EGL_SAMPLES
, /* __DRI_ATTRIB_SAMPLES */
130 0, /* __DRI_ATTRIB_RENDER_TYPE, */
131 0, /* __DRI_ATTRIB_CONFIG_CAVEAT */
132 0, /* __DRI_ATTRIB_CONFORMANT */
133 0, /* __DRI_ATTRIB_DOUBLE_BUFFER */
134 0, /* __DRI_ATTRIB_STEREO */
135 0, /* __DRI_ATTRIB_AUX_BUFFERS */
136 0, /* __DRI_ATTRIB_TRANSPARENT_TYPE */
137 0, /* __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE */
138 0, /* __DRI_ATTRIB_TRANSPARENT_RED_VALUE */
139 0, /* __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE */
140 0, /* __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE */
141 0, /* __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE */
142 0, /* __DRI_ATTRIB_FLOAT_MODE */
143 0, /* __DRI_ATTRIB_RED_MASK */
144 0, /* __DRI_ATTRIB_GREEN_MASK */
145 0, /* __DRI_ATTRIB_BLUE_MASK */
146 0, /* __DRI_ATTRIB_ALPHA_MASK */
147 EGL_MAX_PBUFFER_WIDTH
, /* __DRI_ATTRIB_MAX_PBUFFER_WIDTH */
148 EGL_MAX_PBUFFER_HEIGHT
, /* __DRI_ATTRIB_MAX_PBUFFER_HEIGHT */
149 EGL_MAX_PBUFFER_PIXELS
, /* __DRI_ATTRIB_MAX_PBUFFER_PIXELS */
150 0, /* __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH */
151 0, /* __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT */
152 0, /* __DRI_ATTRIB_VISUAL_SELECT_GROUP */
153 0, /* __DRI_ATTRIB_SWAP_METHOD */
154 EGL_MAX_SWAP_INTERVAL
, /* __DRI_ATTRIB_MAX_SWAP_INTERVAL */
155 EGL_MIN_SWAP_INTERVAL
, /* __DRI_ATTRIB_MIN_SWAP_INTERVAL */
156 0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_RGB */
157 0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA */
158 0, /* __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE */
159 0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
160 0, /* __DRI_ATTRIB_YINVERTED */
164 dri2_add_config(_EGLDisplay
*disp
, const __DRIconfig
*dri_config
, int id
,
165 int depth
, xcb_visualtype_t
*visual
)
167 struct dri2_egl_config
*conf
;
168 struct dri2_egl_display
*dri2_dpy
;
170 unsigned int attrib
, value
, double_buffer
;
171 EGLint key
, bind_to_texture_rgb
, bind_to_texture_rgba
;
174 dri2_dpy
= disp
->DriverData
;
175 _eglInitConfig(&base
, disp
, id
);
178 while (dri2_dpy
->core
->indexConfigAttrib(dri_config
, i
++, &attrib
, &value
)) {
180 case __DRI_ATTRIB_RENDER_TYPE
:
181 if (value
& __DRI_ATTRIB_RGBA_BIT
)
182 value
= EGL_RGB_BUFFER
;
183 else if (value
& __DRI_ATTRIB_LUMINANCE_BIT
)
184 value
= EGL_LUMINANCE_BUFFER
;
187 _eglSetConfigKey(&base
, EGL_COLOR_BUFFER_TYPE
, value
);
190 case __DRI_ATTRIB_CONFIG_CAVEAT
:
191 if (value
& __DRI_ATTRIB_NON_CONFORMANT_CONFIG
)
192 value
= EGL_NON_CONFORMANT_CONFIG
;
193 else if (value
& __DRI_ATTRIB_SLOW_BIT
)
194 value
= EGL_SLOW_CONFIG
;
197 _eglSetConfigKey(&base
, EGL_CONFIG_CAVEAT
, value
);
200 case __DRI_ATTRIB_BIND_TO_TEXTURE_RGB
:
201 bind_to_texture_rgb
= value
;
204 case __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA
:
205 bind_to_texture_rgba
= value
;
208 case __DRI_ATTRIB_DOUBLE_BUFFER
:
209 double_buffer
= value
;
213 key
= dri2_to_egl_attribute_map
[attrib
];
215 _eglSetConfigKey(&base
, key
, value
);
220 /* In EGL, double buffer or not isn't a config attribute. Pixmaps
221 * surfaces are always single buffered, pbuffer surfaces are always
222 * back buffers and windows can be either, selected by passing an
223 * attribute at window surface construction time. To support this
224 * we ignore all double buffer configs and manipulate the buffer we
225 * return in the getBuffer callback to get the behaviour we want. */
230 if (visual
!= NULL
) {
231 if (depth
!= _eglGetConfigKey(&base
, EGL_BUFFER_SIZE
))
234 _eglSetConfigKey(&base
, EGL_SURFACE_TYPE
,
235 EGL_WINDOW_BIT
| EGL_PIXMAP_BIT
| EGL_PBUFFER_BIT
|
236 EGL_SWAP_BEHAVIOR_PRESERVED_BIT
);
238 _eglSetConfigKey(&base
, EGL_NATIVE_VISUAL_ID
, visual
->visual_id
);
239 _eglSetConfigKey(&base
, EGL_NATIVE_VISUAL_TYPE
, visual
->_class
);
241 _eglSetConfigKey(&base
, EGL_SURFACE_TYPE
,
242 EGL_PIXMAP_BIT
| EGL_PBUFFER_BIT
);
245 _eglSetConfigKey(&base
, EGL_NATIVE_RENDERABLE
, EGL_TRUE
);
246 _eglSetConfigKey(&base
, EGL_BIND_TO_TEXTURE_RGB
, bind_to_texture_rgb
);
247 if (_eglGetConfigKey(&base
, EGL_ALPHA_SIZE
) > 0)
248 _eglSetConfigKey(&base
,
249 EGL_BIND_TO_TEXTURE_RGBA
, bind_to_texture_rgba
);
251 /* EGL_OPENGL_ES_BIT, EGL_OPENVG_BIT, EGL_OPENGL_ES2_BIT */
252 _eglSetConfigKey(&base
, EGL_RENDERABLE_TYPE
, EGL_OPENGL_BIT
);
253 _eglSetConfigKey(&base
, EGL_CONFORMANT
, EGL_OPENGL_BIT
);
255 if (!_eglValidateConfig(&base
, EGL_FALSE
)) {
256 _eglLog(_EGL_DEBUG
, "DRI2: failed to validate config %d", id
);
260 conf
= malloc(sizeof *conf
);
262 memcpy(&conf
->base
, &base
, sizeof base
);
263 conf
->dri_config
= dri_config
;
264 _eglAddConfig(disp
, &conf
->base
);
269 * Process list of buffer received from the server
271 * Processes the list of buffers received in a reply from the server to either
272 * \c DRI2GetBuffers or \c DRI2GetBuffersWithFormat.
275 dri2_process_buffers(struct dri2_egl_surface
*dri2_surf
,
276 xcb_dri2_dri2_buffer_t
*buffers
, unsigned count
)
278 struct dri2_egl_display
*dri2_dpy
=
279 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
280 xcb_rectangle_t rectangle
;
283 dri2_surf
->buffer_count
= count
;
284 dri2_surf
->have_fake_front
= 0;
286 /* This assumes the DRI2 buffer attachment tokens matches the
287 * __DRIbuffer tokens. */
288 for (i
= 0; i
< count
; i
++) {
289 dri2_surf
->buffers
[i
].attachment
= buffers
[i
].attachment
;
290 dri2_surf
->buffers
[i
].name
= buffers
[i
].name
;
291 dri2_surf
->buffers
[i
].pitch
= buffers
[i
].pitch
;
292 dri2_surf
->buffers
[i
].cpp
= buffers
[i
].cpp
;
293 dri2_surf
->buffers
[i
].flags
= buffers
[i
].flags
;
295 /* We only use the DRI drivers single buffer configs. This
296 * means that if we try to render to a window, DRI2 will give us
297 * the fake front buffer, which we'll use as a back buffer.
298 * Note that EGL doesn't require that several clients rendering
299 * to the same window must see the same aux buffers. */
300 if (dri2_surf
->buffers
[i
].attachment
== __DRI_BUFFER_FAKE_FRONT_LEFT
)
301 dri2_surf
->have_fake_front
= 1;
304 if (dri2_surf
->region
!= XCB_NONE
)
305 xcb_xfixes_destroy_region(dri2_dpy
->conn
, dri2_surf
->region
);
309 rectangle
.width
= dri2_surf
->base
.Width
;
310 rectangle
.height
= dri2_surf
->base
.Height
;
311 dri2_surf
->region
= xcb_generate_id(dri2_dpy
->conn
);
312 xcb_xfixes_create_region(dri2_dpy
->conn
, dri2_surf
->region
, 1, &rectangle
);
316 dri2_get_buffers(__DRIdrawable
* driDrawable
,
317 int *width
, int *height
,
318 unsigned int *attachments
, int count
,
319 int *out_count
, void *loaderPrivate
)
321 struct dri2_egl_surface
*dri2_surf
= loaderPrivate
;
322 struct dri2_egl_display
*dri2_dpy
=
323 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
324 xcb_dri2_dri2_buffer_t
*buffers
;
325 xcb_dri2_get_buffers_reply_t
*reply
;
326 xcb_dri2_get_buffers_cookie_t cookie
;
328 cookie
= xcb_dri2_get_buffers_unchecked (dri2_dpy
->conn
,
330 count
, count
, attachments
);
331 reply
= xcb_dri2_get_buffers_reply (dri2_dpy
->conn
, cookie
, NULL
);
332 buffers
= xcb_dri2_get_buffers_buffers (reply
);
336 *out_count
= reply
->count
;
337 dri2_surf
->base
.Width
= *width
= reply
->width
;
338 dri2_surf
->base
.Height
= *height
= reply
->height
;
339 dri2_process_buffers(dri2_surf
, buffers
, *out_count
);
343 return dri2_surf
->buffers
;
347 dri2_flush_front_buffer(__DRIdrawable
* driDrawable
, void *loaderPrivate
)
349 /* FIXME: Does EGL support front buffer rendering at all? */
352 struct dri2_egl_surface
*dri2_surf
= loaderPrivate
;
354 dri2WaitGL(dri2_surf
);
359 dri2_lookup_egl_image(__DRIcontext
*context
, void *image
, void *data
)
361 struct dri2_egl_context
*dri2_ctx
= data
;
362 _EGLDisplay
*disp
= dri2_ctx
->base
.Resource
.Display
;
363 struct dri2_egl_image
*dri2_img
;
366 img
= _eglLookupImage(image
, disp
);
368 _eglError(EGL_BAD_PARAMETER
, "dri2_lookup_egl_image");
372 dri2_img
= dri2_egl_image(image
);
374 return dri2_img
->dri_image
;
378 dri2_get_buffers_with_format(__DRIdrawable
* driDrawable
,
379 int *width
, int *height
,
380 unsigned int *attachments
, int count
,
381 int *out_count
, void *loaderPrivate
)
383 struct dri2_egl_surface
*dri2_surf
= loaderPrivate
;
384 struct dri2_egl_display
*dri2_dpy
=
385 dri2_egl_display(dri2_surf
->base
.Resource
.Display
);
386 xcb_dri2_dri2_buffer_t
*buffers
;
387 xcb_dri2_get_buffers_with_format_reply_t
*reply
;
388 xcb_dri2_get_buffers_with_format_cookie_t cookie
;
389 xcb_dri2_attach_format_t
*format_attachments
;
391 format_attachments
= (xcb_dri2_attach_format_t
*) attachments
;
392 cookie
= xcb_dri2_get_buffers_with_format_unchecked (dri2_dpy
->conn
,
397 reply
= xcb_dri2_get_buffers_with_format_reply (dri2_dpy
->conn
,
402 buffers
= xcb_dri2_get_buffers_with_format_buffers (reply
);
403 dri2_surf
->base
.Width
= *width
= reply
->width
;
404 dri2_surf
->base
.Height
= *height
= reply
->height
;
405 *out_count
= reply
->count
;
406 dri2_process_buffers(dri2_surf
, buffers
, *out_count
);
410 return dri2_surf
->buffers
;
414 static const char dri_driver_format
[] = "%.*s/tls/%.*s_dri.so";
416 static const char dri_driver_format
[] = "%.*s/%.*s_dri.so";
419 static const char dri_driver_path
[] = DEFAULT_DRIVER_DIR
;
421 struct dri2_extension_match
{
427 static struct dri2_extension_match dri2_driver_extensions
[] = {
428 { __DRI_CORE
, 1, offsetof(struct dri2_egl_display
, core
) },
429 { __DRI_DRI2
, 1, offsetof(struct dri2_egl_display
, dri2
) },
433 static struct dri2_extension_match dri2_core_extensions
[] = {
434 { __DRI2_FLUSH
, 1, offsetof(struct dri2_egl_display
, flush
) },
435 { __DRI_TEX_BUFFER
, 2, offsetof(struct dri2_egl_display
, tex_buffer
) },
436 { __DRI_IMAGE
, 1, offsetof(struct dri2_egl_display
, image
) },
441 dri2_bind_extensions(struct dri2_egl_display
*dri2_dpy
,
442 struct dri2_extension_match
*matches
,
443 const __DRIextension
**extensions
)
445 int i
, j
, ret
= EGL_TRUE
;
448 for (i
= 0; extensions
[i
]; i
++) {
449 _eglLog(_EGL_DEBUG
, "DRI2: found extension `%s'", extensions
[i
]->name
);
450 for (j
= 0; matches
[j
].name
; j
++) {
451 if (strcmp(extensions
[i
]->name
, matches
[j
].name
) == 0 &&
452 extensions
[i
]->version
>= matches
[j
].version
) {
453 field
= ((char *) dri2_dpy
+ matches
[j
].offset
);
454 *(const __DRIextension
**) field
= extensions
[i
];
455 _eglLog(_EGL_INFO
, "DRI2: found extension %s version %d",
456 extensions
[i
]->name
, extensions
[i
]->version
);
461 for (j
= 0; matches
[j
].name
; j
++) {
462 field
= ((char *) dri2_dpy
+ matches
[j
].offset
);
463 if (*(const __DRIextension
**) field
== NULL
) {
464 _eglLog(_EGL_FATAL
, "DRI2: did not find extension %s version %d",
465 matches
[j
].name
, matches
[j
].version
);
474 * Called via eglInitialize(), GLX_drv->API.Initialize().
477 dri2_initialize(_EGLDriver
*drv
, _EGLDisplay
*disp
,
478 EGLint
*major
, EGLint
*minor
)
480 const __DRIextension
**extensions
;
481 const __DRIconfig
**driver_configs
;
482 struct dri2_egl_display
*dri2_dpy
;
483 char path
[PATH_MAX
], *search_paths
, *p
, *next
, *end
;
484 xcb_xfixes_query_version_reply_t
*xfixes_query
;
485 xcb_xfixes_query_version_cookie_t xfixes_query_cookie
;
486 xcb_dri2_query_version_reply_t
*dri2_query
;
487 xcb_dri2_query_version_cookie_t dri2_query_cookie
;
488 xcb_dri2_connect_reply_t
*connect
;
489 xcb_dri2_connect_cookie_t connect_cookie
;
490 xcb_dri2_authenticate_reply_t
*authenticate
;
491 xcb_dri2_authenticate_cookie_t authenticate_cookie
;
492 xcb_generic_error_t
*error
;
494 xcb_screen_iterator_t s
;
495 xcb_depth_iterator_t d
;
496 xcb_visualtype_t
*visuals
;
499 dri2_dpy
= malloc(sizeof *dri2_dpy
);
501 return _eglError(EGL_BAD_ALLOC
, "eglInitialize");
503 disp
->DriverData
= (void *) dri2_dpy
;
504 if (disp
->NativeDisplay
!= NULL
)
505 dri2_dpy
->conn
= XGetXCBConnection(disp
->NativeDisplay
);
507 dri2_dpy
->conn
= xcb_connect(0, 0);
508 if (!dri2_dpy
->conn
) {
509 _eglLog(_EGL_WARNING
, "DRI2: xcb_connect failed");
513 xcb_prefetch_extension_data (dri2_dpy
->conn
, &xcb_xfixes_id
);
514 xcb_prefetch_extension_data (dri2_dpy
->conn
, &xcb_dri2_id
);
516 xfixes_query_cookie
= xcb_xfixes_query_version(dri2_dpy
->conn
,
517 XCB_XFIXES_MAJOR_VERSION
,
518 XCB_XFIXES_MINOR_VERSION
);
520 dri2_query_cookie
= xcb_dri2_query_version (dri2_dpy
->conn
,
521 XCB_DRI2_MAJOR_VERSION
,
522 XCB_DRI2_MINOR_VERSION
);
524 s
= xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy
->conn
));
525 connect_cookie
= xcb_dri2_connect_unchecked (dri2_dpy
->conn
,
527 XCB_DRI2_DRIVER_TYPE_DRI
);
530 xcb_xfixes_query_version_reply (dri2_dpy
->conn
,
531 xfixes_query_cookie
, &error
);
532 if (xfixes_query
== NULL
||
533 error
!= NULL
|| xfixes_query
->major_version
< 2) {
534 _eglLog(_EGL_FATAL
, "DRI2: failed to query xfixes version");
541 xcb_dri2_query_version_reply (dri2_dpy
->conn
, dri2_query_cookie
, &error
);
542 if (dri2_query
== NULL
|| error
!= NULL
) {
543 _eglLog(_EGL_FATAL
, "DRI2: failed to query version");
547 dri2_dpy
->dri2_major
= dri2_query
->major_version
;
548 dri2_dpy
->dri2_minor
= dri2_query
->minor_version
;
551 connect
= xcb_dri2_connect_reply (dri2_dpy
->conn
, connect_cookie
, NULL
);
552 if (connect
== NULL
||
553 connect
->driver_name_length
+ connect
->device_name_length
== 0) {
554 _eglLog(_EGL_FATAL
, "DRI2: failed to authenticate");
555 goto cleanup_connect
;
559 if (geteuid() == getuid()) {
560 /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
561 search_paths
= getenv("LIBGL_DRIVERS_PATH");
563 if (search_paths
== NULL
)
564 search_paths
= DEFAULT_DRIVER_DIR
;
566 dri2_dpy
->driver
= NULL
;
567 end
= search_paths
+ strlen(search_paths
);
568 for (p
= search_paths
; p
< end
&& dri2_dpy
->driver
== NULL
; p
= next
+ 1) {
569 next
= strchr(p
, ':');
573 snprintf(path
, sizeof path
,
576 xcb_dri2_connect_driver_name_length (connect
),
577 xcb_dri2_connect_driver_name (connect
));
579 dri2_dpy
->driver
= dlopen(path
, RTLD_NOW
| RTLD_GLOBAL
);
582 if (dri2_dpy
->driver
== NULL
) {
584 "DRI2: failed to open any driver (search paths %s)",
586 goto cleanup_connect
;
589 _eglLog(_EGL_DEBUG
, "DRI2: dlopen(%s)", path
);
590 extensions
= dlsym(dri2_dpy
->driver
, __DRI_DRIVER_EXTENSIONS
);
591 if (extensions
== NULL
) {
593 "DRI2: driver exports no extensions (%s)", dlerror());
597 if (!dri2_bind_extensions(dri2_dpy
, dri2_driver_extensions
, extensions
))
600 snprintf(path
, sizeof path
, "%.*s",
601 xcb_dri2_connect_device_name_length (connect
),
602 xcb_dri2_connect_device_name (connect
));
603 dri2_dpy
->fd
= open (path
, O_RDWR
);
604 if (dri2_dpy
->fd
== -1) {
606 "DRI2: could not open %s (%s)", path
, strerror(errno
));
610 if (drmGetMagic(dri2_dpy
->fd
, &magic
)) {
611 _eglLog(_EGL_FATAL
, "DRI2: failed to get drm magic");
615 authenticate_cookie
= xcb_dri2_authenticate_unchecked (dri2_dpy
->conn
,
616 s
.data
->root
, magic
);
617 authenticate
= xcb_dri2_authenticate_reply (dri2_dpy
->conn
,
618 authenticate_cookie
, NULL
);
619 if (authenticate
== NULL
|| !authenticate
->authenticated
) {
620 _eglLog(_EGL_FATAL
, "DRI2: failed to authenticate");
626 if (dri2_dpy
->dri2_minor
>= 1) {
627 dri2_dpy
->loader_extension
.base
.name
= __DRI_DRI2_LOADER
;
628 dri2_dpy
->loader_extension
.base
.version
= 3;
629 dri2_dpy
->loader_extension
.getBuffers
= dri2_get_buffers
;
630 dri2_dpy
->loader_extension
.flushFrontBuffer
= dri2_flush_front_buffer
;
631 dri2_dpy
->loader_extension
.getBuffersWithFormat
=
632 dri2_get_buffers_with_format
;
634 dri2_dpy
->loader_extension
.base
.name
= __DRI_DRI2_LOADER
;
635 dri2_dpy
->loader_extension
.base
.version
= 2;
636 dri2_dpy
->loader_extension
.getBuffers
= dri2_get_buffers
;
637 dri2_dpy
->loader_extension
.flushFrontBuffer
= dri2_flush_front_buffer
;
638 dri2_dpy
->loader_extension
.getBuffersWithFormat
= NULL
;
641 dri2_dpy
->image_lookup_extension
.base
.name
= __DRI_IMAGE_LOOKUP
;
642 dri2_dpy
->image_lookup_extension
.base
.version
= 1;
643 dri2_dpy
->image_lookup_extension
.lookupEGLImage
= dri2_lookup_egl_image
;
645 dri2_dpy
->extensions
[0] = &dri2_dpy
->loader_extension
.base
;
646 dri2_dpy
->extensions
[1] = &dri2_dpy
->image_lookup_extension
.base
;
647 dri2_dpy
->extensions
[2] = NULL
;
649 dri2_dpy
->dri_screen
=
650 dri2_dpy
->dri2
->createNewScreen(0, dri2_dpy
->fd
, dri2_dpy
->extensions
,
651 &driver_configs
, dri2_dpy
);
653 if (dri2_dpy
->dri_screen
== NULL
) {
654 _eglLog(_EGL_FATAL
, "DRI2: failed to create dri screen");
658 extensions
= dri2_dpy
->core
->getExtensions(dri2_dpy
->dri_screen
);
659 if (!dri2_bind_extensions(dri2_dpy
, dri2_core_extensions
, extensions
))
660 goto cleanup_dri_screen
;
662 s
= xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy
->conn
));
663 d
= xcb_screen_allowed_depths_iterator(s
.data
);
666 EGLBoolean class_added
[6] = { 0, };
668 visuals
= xcb_depth_visuals(d
.data
);
669 for (i
= 0; i
< xcb_depth_visuals_length(d
.data
); i
++) {
670 if (class_added
[visuals
[i
]._class
])
673 class_added
[visuals
[i
]._class
] = EGL_TRUE
;
674 for (j
= 0; driver_configs
[j
]; j
++)
675 dri2_add_config(disp
, driver_configs
[j
],
676 id
++, d
.data
->depth
, &visuals
[i
]);
683 if (!disp
->NumConfigs
) {
684 _eglLog(_EGL_WARNING
, "DRI2: failed to create any config");
685 goto cleanup_configs
;
688 disp
->ClientAPIsMask
= EGL_OPENGL_BIT
;
689 disp
->Extensions
.KHR_image_base
= EGL_TRUE
;
690 disp
->Extensions
.KHR_image_pixmap
= EGL_TRUE
;
691 disp
->Extensions
.KHR_gl_renderbuffer_image
= EGL_TRUE
;
693 /* we're supporting EGL 1.4 */
700 _eglCleanupDisplay(disp
);
702 dri2_dpy
->core
->destroyScreen(dri2_dpy
->dri_screen
);
706 dlclose(dri2_dpy
->driver
);
710 if (disp
->NativeDisplay
== NULL
)
711 xcb_disconnect(dri2_dpy
->conn
);
719 * Called via eglTerminate(), drv->API.Terminate().
722 dri2_terminate(_EGLDriver
*drv
, _EGLDisplay
*disp
)
724 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
726 _eglReleaseDisplayResources(drv
, disp
);
727 _eglCleanupDisplay(disp
);
729 dri2_dpy
->core
->destroyScreen(dri2_dpy
->dri_screen
);
731 dlclose(dri2_dpy
->driver
);
732 if (disp
->NativeDisplay
== NULL
)
733 xcb_disconnect(dri2_dpy
->conn
);
735 disp
->DriverData
= NULL
;
742 * Called via eglCreateContext(), drv->API.CreateContext().
745 dri2_create_context(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLConfig
*conf
,
746 _EGLContext
*share_list
, const EGLint
*attrib_list
)
748 struct dri2_egl_context
*dri2_ctx
;
749 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
750 struct dri2_egl_context
*dri2_ctx_shared
= dri2_egl_context(share_list
);
751 struct dri2_egl_config
*dri2_config
= dri2_egl_config(conf
);
753 dri2_ctx
= malloc(sizeof *dri2_ctx
);
755 _eglError(EGL_BAD_ALLOC
, "eglCreateContext");
759 if (!_eglInitContext(&dri2_ctx
->base
, disp
, conf
, attrib_list
))
762 dri2_ctx
->dri_context
=
763 dri2_dpy
->dri2
->createNewContext(dri2_dpy
->dri_screen
,
764 dri2_config
->dri_config
,
766 dri2_ctx_shared
->dri_context
: NULL
,
769 if (!dri2_ctx
->dri_context
)
772 return &dri2_ctx
->base
;
780 dri2_destroy_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*surf
)
782 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
783 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(surf
);
785 if (_eglIsSurfaceBound(surf
))
788 (*dri2_dpy
->core
->destroyDrawable
)(dri2_surf
->dri_drawable
);
790 xcb_dri2_destroy_drawable (dri2_dpy
->conn
, dri2_surf
->drawable
);
792 if (surf
->Type
== EGL_PBUFFER_BIT
)
793 xcb_free_pixmap (dri2_dpy
->conn
, dri2_surf
->drawable
);
801 * Called via eglMakeCurrent(), drv->API.MakeCurrent().
804 dri2_make_current(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*dsurf
,
805 _EGLSurface
*rsurf
, _EGLContext
*ctx
)
807 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
808 struct dri2_egl_surface
*dri2_dsurf
= dri2_egl_surface(dsurf
);
809 struct dri2_egl_surface
*dri2_rsurf
= dri2_egl_surface(rsurf
);
810 struct dri2_egl_context
*dri2_ctx
= dri2_egl_context(ctx
);
811 __DRIdrawable
*ddraw
, *rdraw
;
814 /* bind the new context and return the "orphaned" one */
815 if (!_eglBindContext(&ctx
, &dsurf
, &rsurf
))
818 ddraw
= (dri2_dsurf
) ? dri2_dsurf
->dri_drawable
: NULL
;
819 rdraw
= (dri2_rsurf
) ? dri2_rsurf
->dri_drawable
: NULL
;
820 cctx
= (dri2_ctx
) ? dri2_ctx
->dri_context
: NULL
;
822 if ((cctx
== NULL
&& ddraw
== NULL
&& rdraw
== NULL
) ||
823 dri2_dpy
->core
->bindContext(cctx
, ddraw
, rdraw
)) {
824 if (dsurf
&& !_eglIsSurfaceLinked(dsurf
))
825 dri2_destroy_surface(drv
, disp
, dsurf
);
826 if (rsurf
&& rsurf
!= dsurf
&& !_eglIsSurfaceLinked(dsurf
))
827 dri2_destroy_surface(drv
, disp
, rsurf
);
828 if (ctx
!= NULL
&& !_eglIsContextLinked(ctx
))
829 dri2_dpy
->core
->unbindContext(dri2_egl_context(ctx
)->dri_context
);
833 _eglBindContext(&ctx
, &dsurf
, &rsurf
);
840 * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
843 dri2_create_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
, EGLint type
,
844 _EGLConfig
*conf
, EGLNativeWindowType window
,
845 const EGLint
*attrib_list
)
847 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
848 struct dri2_egl_config
*dri2_conf
= dri2_egl_config(conf
);
849 struct dri2_egl_surface
*dri2_surf
;
850 xcb_get_geometry_cookie_t cookie
;
851 xcb_get_geometry_reply_t
*reply
;
852 xcb_screen_iterator_t s
;
853 xcb_generic_error_t
*error
;
855 dri2_surf
= malloc(sizeof *dri2_surf
);
857 _eglError(EGL_BAD_ALLOC
, "dri2_create_surface");
861 if (!_eglInitSurface(&dri2_surf
->base
, disp
, type
, conf
, attrib_list
))
864 dri2_surf
->region
= XCB_NONE
;
865 if (type
== EGL_PBUFFER_BIT
) {
866 dri2_surf
->drawable
= xcb_generate_id(dri2_dpy
->conn
);
867 s
= xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy
->conn
));
868 xcb_create_pixmap(dri2_dpy
->conn
,
869 _eglGetConfigKey(conf
, EGL_BUFFER_SIZE
),
870 dri2_surf
->drawable
, s
.data
->root
,
871 dri2_surf
->base
.Width
, dri2_surf
->base
.Height
);
873 dri2_surf
->drawable
= window
;
876 dri2_surf
->dri_drawable
=
877 (*dri2_dpy
->dri2
->createNewDrawable
) (dri2_dpy
->dri_screen
,
878 dri2_conf
->dri_config
, dri2_surf
);
879 if (dri2_surf
->dri_drawable
== NULL
) {
880 _eglError(EGL_BAD_ALLOC
, "dri2->createNewDrawable");
884 xcb_dri2_create_drawable (dri2_dpy
->conn
, dri2_surf
->drawable
);
886 if (type
!= EGL_PBUFFER_BIT
) {
887 cookie
= xcb_get_geometry (dri2_dpy
->conn
, dri2_surf
->drawable
);
888 reply
= xcb_get_geometry_reply (dri2_dpy
->conn
, cookie
, &error
);
889 if (reply
== NULL
|| error
!= NULL
) {
890 _eglError(EGL_BAD_ALLOC
, "xcb_get_geometry");
892 goto cleanup_dri_drawable
;
895 dri2_surf
->base
.Width
= reply
->width
;
896 dri2_surf
->base
.Height
= reply
->height
;
900 return &dri2_surf
->base
;
902 cleanup_dri_drawable
:
903 dri2_dpy
->core
->destroyDrawable(dri2_surf
->dri_drawable
);
905 if (type
== EGL_PBUFFER_BIT
)
906 xcb_free_pixmap(dri2_dpy
->conn
, dri2_surf
->drawable
);
914 * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
917 dri2_create_window_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
,
918 _EGLConfig
*conf
, EGLNativeWindowType window
,
919 const EGLint
*attrib_list
)
921 return dri2_create_surface(drv
, disp
, EGL_WINDOW_BIT
, conf
,
922 window
, attrib_list
);
926 dri2_create_pixmap_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
,
927 _EGLConfig
*conf
, EGLNativePixmapType pixmap
,
928 const EGLint
*attrib_list
)
930 return dri2_create_surface(drv
, disp
, EGL_PIXMAP_BIT
, conf
,
931 pixmap
, attrib_list
);
935 dri2_create_pbuffer_surface(_EGLDriver
*drv
, _EGLDisplay
*disp
,
936 _EGLConfig
*conf
, const EGLint
*attrib_list
)
938 return dri2_create_surface(drv
, disp
, EGL_PBUFFER_BIT
, conf
,
939 XCB_WINDOW_NONE
, attrib_list
);
943 dri2_swap_buffers(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*draw
)
945 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
946 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(draw
);
947 xcb_dri2_copy_region_cookie_t cookie
;
949 (*dri2_dpy
->flush
->flush
)(dri2_surf
->dri_drawable
);
952 /* FIXME: Add support for dri swapbuffers, that'll give us swap
953 * interval and page flipping (at least for fullscreen windows) as
954 * well as the page flip event. Unless surface->SwapBehavior is
955 * EGL_BUFFER_PRESERVED. */
956 #if __DRI2_FLUSH_VERSION >= 2
958 (*pdraw
->psc
->f
->flushInvalidate
)(pdraw
->driDrawable
);
962 if (!dri2_surf
->have_fake_front
)
965 cookie
= xcb_dri2_copy_region_unchecked(dri2_dpy
->conn
,
968 XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT
,
969 XCB_DRI2_ATTACHMENT_BUFFER_FAKE_FRONT_LEFT
);
970 free(xcb_dri2_copy_region_reply(dri2_dpy
->conn
, cookie
, NULL
));
976 * Called from eglGetProcAddress() via drv->API.GetProcAddress().
979 dri2_get_proc_address(_EGLDriver
*drv
, const char *procname
)
981 /* FIXME: Do we need to support lookup of EGL symbols too? */
983 return (_EGLProc
) _glapi_get_proc_address(procname
);
987 dri2_wait_client(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLContext
*ctx
)
989 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
990 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(ctx
->DrawSurface
);
992 /* FIXME: If EGL allows frontbuffer rendering for window surfaces,
993 * we need to copy fake to real here.*/
995 (*dri2_dpy
->flush
->flush
)(dri2_surf
->dri_drawable
);
1001 dri2_wait_native(_EGLDriver
*drv
, _EGLDisplay
*disp
, EGLint engine
)
1003 if (engine
!= EGL_CORE_NATIVE_ENGINE
)
1004 return _eglError(EGL_BAD_PARAMETER
, "eglWaitNative");
1011 dri2_unload(_EGLDriver
*drv
)
1013 struct dri2_egl_driver
*dri2_drv
= dri2_egl_driver(drv
);
1018 dri2_copy_buffers(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLSurface
*surf
,
1019 EGLNativePixmapType target
)
1021 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
1022 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(surf
);
1025 (*dri2_dpy
->flush
->flush
)(dri2_surf
->dri_drawable
);
1027 gc
= xcb_generate_id(dri2_dpy
->conn
);
1028 xcb_create_gc(dri2_dpy
->conn
, gc
, target
, 0, NULL
);
1029 xcb_copy_area(dri2_dpy
->conn
,
1030 dri2_surf
->drawable
,
1035 dri2_surf
->base
.Width
,
1036 dri2_surf
->base
.Height
);
1037 xcb_free_gc(dri2_dpy
->conn
, gc
);
1043 dri2_bind_tex_image(_EGLDriver
*drv
,
1044 _EGLDisplay
*disp
, _EGLSurface
*surf
, EGLint buffer
)
1046 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
1047 struct dri2_egl_surface
*dri2_surf
= dri2_egl_surface(surf
);
1048 struct dri2_egl_context
*dri2_ctx
;
1050 GLint format
, target
;
1052 ctx
= _eglGetCurrentContext();
1053 dri2_ctx
= dri2_egl_context(ctx
);
1055 if (buffer
!= EGL_BACK_BUFFER
) {
1056 _eglError(EGL_BAD_PARAMETER
, "eglBindTexImage");
1060 /* We allow binding pixmaps too... Not conformat, but we can do it
1061 * for free and it's useful for X compositors. Supposedly there's
1062 * a EGL_NOKIA_texture_from_pixmap extension that allows that, but
1063 * I couldn't find it at this time. */
1064 if ((dri2_surf
->base
.Type
& (EGL_PBUFFER_BIT
| EGL_PIXMAP_BIT
)) == 0) {
1065 _eglError(EGL_BAD_SURFACE
, "eglBindTexImage");
1069 switch (dri2_surf
->base
.TextureFormat
) {
1070 case EGL_TEXTURE_RGB
:
1071 format
= __DRI_TEXTURE_FORMAT_RGB
;
1073 case EGL_TEXTURE_RGBA
:
1074 format
= __DRI_TEXTURE_FORMAT_RGBA
;
1077 _eglError(EGL_BAD_MATCH
, "eglBindTexImage");
1081 switch (dri2_surf
->base
.TextureTarget
) {
1082 case EGL_TEXTURE_2D
:
1083 target
= GL_TEXTURE_2D
;
1086 _eglError(EGL_BAD_PARAMETER
, "eglBindTexImage");
1090 (*dri2_dpy
->tex_buffer
->setTexBuffer2
)(dri2_ctx
->dri_context
,
1092 dri2_surf
->dri_drawable
);
1094 return dri2_surf
->base
.BoundToTexture
= EGL_TRUE
;
1098 dri2_release_tex_image(_EGLDriver
*drv
,
1099 _EGLDisplay
*disp
, _EGLSurface
*surf
, EGLint buffer
)
1105 dri2_create_image_khr_pixmap(_EGLDisplay
*disp
, _EGLContext
*ctx
,
1106 EGLClientBuffer buffer
, const EGLint
*attr_list
)
1108 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
1109 struct dri2_egl_context
*dri2_ctx
= dri2_egl_context(ctx
);
1110 struct dri2_egl_image
*dri2_img
;
1111 unsigned int attachments
[1];
1112 xcb_drawable_t drawable
;
1113 xcb_dri2_get_buffers_cookie_t buffers_cookie
;
1114 xcb_dri2_get_buffers_reply_t
*buffers_reply
;
1115 xcb_dri2_dri2_buffer_t
*buffers
;
1116 xcb_get_geometry_cookie_t geometry_cookie
;
1117 xcb_get_geometry_reply_t
*geometry_reply
;
1118 xcb_generic_error_t
*error
;
1121 drawable
= (xcb_drawable_t
) buffer
;
1122 xcb_dri2_create_drawable (dri2_dpy
->conn
, drawable
);
1123 attachments
[0] = XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT
;
1125 xcb_dri2_get_buffers_unchecked (dri2_dpy
->conn
,
1126 drawable
, 1, 1, attachments
);
1127 geometry_cookie
= xcb_get_geometry (dri2_dpy
->conn
, drawable
);
1128 buffers_reply
= xcb_dri2_get_buffers_reply (dri2_dpy
->conn
,
1129 buffers_cookie
, NULL
);
1130 buffers
= xcb_dri2_get_buffers_buffers (buffers_reply
);
1131 if (buffers
== NULL
) {
1135 geometry_reply
= xcb_get_geometry_reply (dri2_dpy
->conn
,
1136 geometry_cookie
, &error
);
1137 if (geometry_reply
== NULL
|| error
!= NULL
) {
1138 _eglError(EGL_BAD_ALLOC
, "xcb_get_geometry");
1140 free(buffers_reply
);
1143 switch (geometry_reply
->depth
) {
1145 format
= __DRI_IMAGE_FORMAT_RGB565
;
1148 format
= __DRI_IMAGE_FORMAT_XRGB8888
;
1151 format
= __DRI_IMAGE_FORMAT_ARGB8888
;
1154 _eglError(EGL_BAD_PARAMETER
,
1155 "dri2_create_image_khr: unsupported pixmap depth");
1156 free(buffers_reply
);
1157 free(geometry_reply
);
1161 dri2_img
= malloc(sizeof *dri2_img
);
1163 free(buffers_reply
);
1164 free(geometry_reply
);
1165 _eglError(EGL_BAD_ALLOC
, "dri2_create_image_khr");
1166 return EGL_NO_IMAGE_KHR
;
1169 if (!_eglInitImage(&dri2_img
->base
, disp
, attr_list
)) {
1170 free(buffers_reply
);
1171 free(geometry_reply
);
1172 return EGL_NO_IMAGE_KHR
;
1175 stride
= buffers
[0].pitch
/ buffers
[0].cpp
;
1176 dri2_img
->dri_image
=
1177 dri2_dpy
->image
->createImageFromName(dri2_ctx
->dri_context
,
1178 buffers_reply
->width
,
1179 buffers_reply
->height
,
1185 free(buffers_reply
);
1186 free(geometry_reply
);
1188 return &dri2_img
->base
;
1192 dri2_create_image_khr_renderbuffer(_EGLDisplay
*disp
, _EGLContext
*ctx
,
1193 EGLClientBuffer buffer
,
1194 const EGLint
*attr_list
)
1196 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
1197 struct dri2_egl_context
*dri2_ctx
= dri2_egl_context(ctx
);
1198 struct dri2_egl_image
*dri2_img
;
1199 GLuint renderbuffer
= (GLuint
) buffer
;
1201 if (renderbuffer
== 0) {
1202 _eglError(EGL_BAD_PARAMETER
, "dri2_create_image_khr");
1203 return EGL_NO_IMAGE_KHR
;
1206 dri2_img
= malloc(sizeof *dri2_img
);
1208 _eglError(EGL_BAD_ALLOC
, "dri2_create_image_khr");
1209 return EGL_NO_IMAGE_KHR
;
1212 if (!_eglInitImage(&dri2_img
->base
, disp
, attr_list
))
1213 return EGL_NO_IMAGE_KHR
;
1215 dri2_img
->dri_image
=
1216 dri2_dpy
->image
->createImageFromRenderbuffer(dri2_ctx
->dri_context
,
1220 return &dri2_img
->base
;
1224 dri2_create_image_khr(_EGLDriver
*drv
, _EGLDisplay
*disp
,
1225 _EGLContext
*ctx
, EGLenum target
,
1226 EGLClientBuffer buffer
, const EGLint
*attr_list
)
1229 case EGL_NATIVE_PIXMAP_KHR
:
1230 return dri2_create_image_khr_pixmap(disp
, ctx
, buffer
, attr_list
);
1231 case EGL_GL_RENDERBUFFER_KHR
:
1232 return dri2_create_image_khr_renderbuffer(disp
, ctx
, buffer
, attr_list
);
1234 _eglError(EGL_BAD_PARAMETER
, "dri2_create_image_khr");
1235 return EGL_NO_IMAGE_KHR
;
1240 dri2_destroy_image_khr(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLImage
*image
)
1242 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
1243 struct dri2_egl_image
*dri2_img
= dri2_egl_image(image
);
1245 dri2_dpy
->image
->destroyImage(dri2_img
->dri_image
);
1252 * This is the main entrypoint into the driver, called by libEGL.
1253 * Create a new _EGLDriver object and init its dispatch table.
1256 _eglMain(const char *args
)
1258 struct dri2_egl_driver
*dri2_drv
;
1260 dri2_drv
= malloc(sizeof *dri2_drv
);
1264 _eglInitDriverFallbacks(&dri2_drv
->base
);
1265 dri2_drv
->base
.API
.Initialize
= dri2_initialize
;
1266 dri2_drv
->base
.API
.Terminate
= dri2_terminate
;
1267 dri2_drv
->base
.API
.CreateContext
= dri2_create_context
;
1268 dri2_drv
->base
.API
.MakeCurrent
= dri2_make_current
;
1269 dri2_drv
->base
.API
.CreateWindowSurface
= dri2_create_window_surface
;
1270 dri2_drv
->base
.API
.CreatePixmapSurface
= dri2_create_pixmap_surface
;
1271 dri2_drv
->base
.API
.CreatePbufferSurface
= dri2_create_pbuffer_surface
;
1272 dri2_drv
->base
.API
.DestroySurface
= dri2_destroy_surface
;
1273 dri2_drv
->base
.API
.SwapBuffers
= dri2_swap_buffers
;
1274 dri2_drv
->base
.API
.GetProcAddress
= dri2_get_proc_address
;
1275 dri2_drv
->base
.API
.WaitClient
= dri2_wait_client
;
1276 dri2_drv
->base
.API
.WaitNative
= dri2_wait_native
;
1277 dri2_drv
->base
.API
.CopyBuffers
= dri2_copy_buffers
;
1278 dri2_drv
->base
.API
.BindTexImage
= dri2_bind_tex_image
;
1279 dri2_drv
->base
.API
.ReleaseTexImage
= dri2_release_tex_image
;
1280 dri2_drv
->base
.API
.CreateImageKHR
= dri2_create_image_khr
;
1281 dri2_drv
->base
.API
.DestroyImageKHR
= dri2_destroy_image_khr
;
1283 dri2_drv
->base
.Name
= "DRI2";
1284 dri2_drv
->base
.Unload
= dri2_unload
;
1286 return &dri2_drv
->base
;