1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 * EGL / softpipe / xlib winsys module
36 #include <X11/Xutil.h>
38 #include "pipe/p_compiler.h"
39 #include "pipe/p_format.h"
40 #include "pipe/p_state.h"
41 #include "pipe/internal/p_winsys_screen.h"
42 #include "util/u_memory.h"
43 #include "softpipe/sp_winsys.h"
44 #include "softpipe/sp_texture.h"
46 #include "eglconfig.h"
47 #include "eglconfigutil.h"
48 #include "eglcontext.h"
49 #include "egldisplay.h"
50 #include "egldriver.h"
51 #include "eglglobals.h"
53 #include "eglsurface.h"
55 #include "state_tracker/st_public.h"
57 #include "sw_winsys.h"
60 /** subclass of _EGLDriver */
61 struct xlib_egl_driver
63 _EGLDriver Base
; /**< base class */
65 struct pipe_winsys
*winsys
;
66 struct pipe_screen
*screen
;
70 /** subclass of _EGLContext */
71 struct xlib_egl_context
73 _EGLContext Base
; /**< base class */
75 struct pipe_context
*pipe
; /**< Gallium driver context */
76 struct st_context
*Context
; /**< Mesa/gallium state tracker context */
80 /** subclass of _EGLSurface */
81 struct xlib_egl_surface
83 _EGLSurface Base
; /**< base class */
85 /* These are set for window surface */
86 Display
*Dpy
; /**< The X Display of the window */
87 Window Win
; /**< The user-created window ID */
91 struct pipe_winsys
*winsys
;
93 struct st_framebuffer
*Framebuffer
;
98 static INLINE
struct xlib_egl_driver
*
99 xlib_egl_driver(_EGLDriver
*drv
)
101 return (struct xlib_egl_driver
*) drv
;
105 static INLINE
struct xlib_egl_surface
*
106 lookup_surface(_EGLSurface
*surf
)
108 return (struct xlib_egl_surface
*) surf
;
112 static INLINE
struct xlib_egl_context
*
113 lookup_context(_EGLContext
*ctx
)
115 return (struct xlib_egl_context
*) ctx
;
120 bitcount(unsigned int n
)
123 for (bits
= 0; n
> 0; n
= n
>> 1) {
131 * Create the EGLConfigs. (one per X visual)
134 create_configs(_EGLDriver
*drv
, _EGLDisplay
*disp
)
136 static const EGLint all_apis
= (EGL_OPENGL_ES_BIT
|
140 XVisualInfo
*visInfo
, visTemplate
;
143 /* get list of all X visuals, create an EGL config for each */
144 visTemplate
.screen
= DefaultScreen(disp
->Xdpy
);
145 visInfo
= XGetVisualInfo(disp
->Xdpy
, VisualScreenMask
,
146 &visTemplate
, &num_visuals
);
148 printf("egl_xlib.c: couldn't get any X visuals\n");
152 for (i
= 0; i
< num_visuals
; i
++) {
153 _EGLConfig
*config
= calloc(1, sizeof(_EGLConfig
));
155 int rbits
= bitcount(visInfo
[i
].red_mask
);
156 int gbits
= bitcount(visInfo
[i
].green_mask
);
157 int bbits
= bitcount(visInfo
[i
].blue_mask
);
158 int abits
= bbits
== 8 ? 8 : 0;
161 int visid
= visInfo
[i
].visualid
;
162 #if defined(__cplusplus) || defined(c_plusplus)
163 int vistype
= visInfo
[i
].c_class
;
165 int vistype
= visInfo
[i
].class;
168 _eglInitConfig(config
, id
);
169 SET_CONFIG_ATTRIB(config
, EGL_BUFFER_SIZE
, rbits
+ gbits
+ bbits
+ abits
);
170 SET_CONFIG_ATTRIB(config
, EGL_RED_SIZE
, rbits
);
171 SET_CONFIG_ATTRIB(config
, EGL_GREEN_SIZE
, gbits
);
172 SET_CONFIG_ATTRIB(config
, EGL_BLUE_SIZE
, bbits
);
173 SET_CONFIG_ATTRIB(config
, EGL_ALPHA_SIZE
, abits
);
174 SET_CONFIG_ATTRIB(config
, EGL_DEPTH_SIZE
, zbits
);
175 SET_CONFIG_ATTRIB(config
, EGL_STENCIL_SIZE
, sbits
);
176 SET_CONFIG_ATTRIB(config
, EGL_NATIVE_VISUAL_ID
, visid
);
177 SET_CONFIG_ATTRIB(config
, EGL_NATIVE_VISUAL_TYPE
, vistype
);
178 SET_CONFIG_ATTRIB(config
, EGL_NATIVE_RENDERABLE
, EGL_FALSE
);
179 SET_CONFIG_ATTRIB(config
, EGL_CONFORMANT
, all_apis
);
180 SET_CONFIG_ATTRIB(config
, EGL_RENDERABLE_TYPE
, all_apis
);
181 SET_CONFIG_ATTRIB(config
, EGL_SURFACE_TYPE
, EGL_WINDOW_BIT
| EGL_PBUFFER_BIT
);
182 SET_CONFIG_ATTRIB(config
, EGL_BIND_TO_TEXTURE_RGBA
, EGL_TRUE
);
183 SET_CONFIG_ATTRIB(config
, EGL_BIND_TO_TEXTURE_RGB
, EGL_TRUE
);
185 _eglAddConfig(disp
, config
);
191 * Called via eglInitialize(), drv->API.Initialize().
194 xlib_eglInitialize(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
195 EGLint
*minor
, EGLint
*major
)
197 create_configs(drv
, dpy
);
199 drv
->Initialized
= EGL_TRUE
;
201 /* we're supporting EGL 1.4 */
210 * Called via eglTerminate(), drv->API.Terminate().
213 xlib_eglTerminate(_EGLDriver
*drv
, _EGLDisplay
*dpy
)
220 xlib_eglGetProcAddress(const char *procname
)
222 return (_EGLProc
) st_get_proc_address(procname
);
227 get_drawable_visual_info(Display
*dpy
, Drawable d
, XVisualInfo
*visInfo
)
229 XWindowAttributes attr
;
230 XVisualInfo visTemp
, *vis
;
233 XGetWindowAttributes(dpy
, d
, &attr
);
235 visTemp
.screen
= DefaultScreen(dpy
);
236 visTemp
.visualid
= attr
.visual
->visualid
;
237 vis
= XGetVisualInfo(dpy
,
238 (VisualScreenMask
| VisualIDMask
),
239 &visTemp
, &num_visuals
);
248 /** Get size of given window */
250 get_drawable_size(Display
*dpy
, Drawable d
, uint
*width
, uint
*height
)
255 unsigned int w
, h
, bw
, depth
;
256 stat
= XGetGeometry(dpy
, d
, &root
, &xpos
, &ypos
, &w
, &h
, &bw
, &depth
);
264 check_and_update_buffer_size(struct xlib_egl_surface
*surface
)
267 if (surface
->Base
.Type
== EGL_PBUFFER_BIT
) {
268 width
= surface
->Base
.Width
;
269 height
= surface
->Base
.Height
;
272 get_drawable_size(surface
->Dpy
, surface
->Win
, &width
, &height
);
274 st_resize_framebuffer(surface
->Framebuffer
, width
, height
);
275 surface
->Base
.Width
= width
;
276 surface
->Base
.Height
= height
;
282 display_surface(struct pipe_winsys
*pws
,
283 struct pipe_surface
*psurf
,
284 struct xlib_egl_surface
*xsurf
)
286 struct softpipe_texture
*spt
= softpipe_texture(psurf
->texture
);
290 if (xsurf
->Base
.Type
== EGL_PBUFFER_BIT
)
293 ximage
= XCreateImage(xsurf
->Dpy
,
294 xsurf
->VisInfo
.visual
,
295 xsurf
->VisInfo
.depth
,
296 ZPixmap
, 0, /* format, offset */
300 0); /* bytes_per_line */
303 assert(ximage
->format
);
304 assert(ximage
->bitmap_unit
);
306 data
= pws
->buffer_map(pws
, spt
->buffer
, 0);
308 /* update XImage's fields */
310 ximage
->width
= psurf
->width
;
311 ximage
->height
= psurf
->height
;
312 ximage
->bytes_per_line
= spt
->stride
[psurf
->level
];
314 XPutImage(xsurf
->Dpy
, xsurf
->Win
, xsurf
->Gc
,
315 ximage
, 0, 0, 0, 0, psurf
->width
, psurf
->height
);
317 XSync(xsurf
->Dpy
, 0);
320 XDestroyImage(ximage
);
322 pws
->buffer_unmap(pws
, spt
->buffer
);
327 /** Display gallium surface in X window */
329 flush_frontbuffer(struct pipe_winsys
*pws
,
330 struct pipe_surface
*psurf
,
331 void *context_private
)
333 struct xlib_egl_surface
*xsurf
= (struct xlib_egl_surface
*) context_private
;
334 display_surface(pws
, psurf
, xsurf
);
340 * Called via eglCreateContext(), drv->API.CreateContext().
343 xlib_eglCreateContext(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
,
344 _EGLContext
*share_list
, const EGLint
*attrib_list
)
346 struct xlib_egl_driver
*xdrv
= xlib_egl_driver(drv
);
347 struct xlib_egl_context
*ctx
;
348 struct st_context
*share_ctx
= NULL
; /* XXX fix */
349 __GLcontextModes visual
;
351 ctx
= CALLOC_STRUCT(xlib_egl_context
);
355 /* let EGL lib init the common stuff */
356 if (!_eglInitContext(drv
, &ctx
->Base
, conf
, attrib_list
)) {
361 /* API-dependent context creation */
362 switch (ctx
->Base
.ClientAPI
) {
364 case EGL_OPENGL_ES_API
:
365 _eglLog(_EGL_DEBUG
, "Create Context for ES version %d\n",
366 ctx
->Base
.ClientVersion
);
369 /* create a softpipe context */
370 ctx
->pipe
= softpipe_create(xdrv
->screen
);
371 /* Now do xlib / state tracker inits here */
372 _eglConfigToContextModesRec(conf
, &visual
);
373 ctx
->Context
= st_create_context(ctx
->pipe
, &visual
, share_ctx
);
376 _eglError(EGL_BAD_MATCH
, "eglCreateContext(unsupported API)");
386 xlib_eglDestroyContext(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLContext
*ctx
)
388 struct xlib_egl_context
*context
= lookup_context(ctx
);
390 if (!_eglIsContextBound(&context
->Base
)) {
391 /* API-dependent clean-up */
392 switch (context
->Base
.ClientAPI
) {
393 case EGL_OPENGL_ES_API
:
397 st_destroy_context(context
->Context
);
409 * Called via eglMakeCurrent(), drv->API.MakeCurrent().
412 xlib_eglMakeCurrent(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
413 _EGLSurface
*draw
, _EGLSurface
*read
, _EGLContext
*ctx
)
415 struct xlib_egl_context
*context
= lookup_context(ctx
);
416 struct xlib_egl_surface
*draw_surf
= lookup_surface(draw
);
417 struct xlib_egl_surface
*read_surf
= lookup_surface(read
);
418 struct st_context
*oldctx
= st_get_current();
420 if (!_eglMakeCurrent(drv
, dpy
, draw
, read
, ctx
))
423 /* Flush before switching context. Check client API? */
425 st_flush(oldctx
, PIPE_FLUSH_RENDER_CACHE
| PIPE_FLUSH_FRAME
, NULL
);
426 st_make_current((context
? context
->Context
: NULL
),
427 (draw_surf
? draw_surf
->Framebuffer
: NULL
),
428 (read_surf
? read_surf
->Framebuffer
: NULL
));
431 check_and_update_buffer_size(draw_surf
);
432 if (read_surf
&& read_surf
!= draw_surf
)
433 check_and_update_buffer_size(draw_surf
);
439 static enum pipe_format
440 choose_color_format(const __GLcontextModes
*visual
)
442 if (visual
->redBits
== 8 &&
443 visual
->greenBits
== 8 &&
444 visual
->blueBits
== 8 &&
445 visual
->alphaBits
== 8) {
446 /* XXX this really also depends on the ordering of R,G,B,A */
447 return PIPE_FORMAT_A8R8G8B8_UNORM
;
451 return PIPE_FORMAT_NONE
;
456 static enum pipe_format
457 choose_depth_format(const __GLcontextModes
*visual
)
459 if (visual
->depthBits
> 0)
460 return PIPE_FORMAT_S8Z24_UNORM
;
462 return PIPE_FORMAT_NONE
;
466 static enum pipe_format
467 choose_stencil_format(const __GLcontextModes
*visual
)
469 if (visual
->stencilBits
> 0)
470 return PIPE_FORMAT_S8Z24_UNORM
;
472 return PIPE_FORMAT_NONE
;
477 * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface().
480 xlib_eglCreateWindowSurface(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLConfig
*conf
,
481 NativeWindowType window
, const EGLint
*attrib_list
)
483 struct xlib_egl_driver
*xdrv
= xlib_egl_driver(drv
);
484 struct xlib_egl_surface
*surf
;
485 __GLcontextModes visual
;
488 surf
= CALLOC_STRUCT(xlib_egl_surface
);
492 /* Let EGL lib init the common stuff */
493 if (!_eglInitSurface(drv
, &surf
->Base
, EGL_WINDOW_BIT
,
494 conf
, attrib_list
)) {
500 * Now init the Xlib and gallium stuff
502 surf
->Win
= (Window
) window
; /* The X window ID */
503 surf
->Dpy
= disp
->Xdpy
; /* The X display */
504 surf
->Gc
= XCreateGC(surf
->Dpy
, surf
->Win
, 0, NULL
);
506 surf
->winsys
= xdrv
->winsys
;
508 _eglConfigToContextModesRec(conf
, &visual
);
509 get_drawable_size(surf
->Dpy
, surf
->Win
, &width
, &height
);
510 get_drawable_visual_info(surf
->Dpy
, surf
->Win
, &surf
->VisInfo
);
512 surf
->Base
.Width
= width
;
513 surf
->Base
.Height
= height
;
515 /* Create GL statetracker framebuffer */
516 surf
->Framebuffer
= st_create_framebuffer(&visual
,
517 choose_color_format(&visual
),
518 choose_depth_format(&visual
),
519 choose_stencil_format(&visual
),
523 st_resize_framebuffer(surf
->Framebuffer
, width
, height
);
530 xlib_eglCreatePbufferSurface(_EGLDriver
*drv
, _EGLDisplay
*disp
, _EGLConfig
*conf
,
531 const EGLint
*attrib_list
)
533 struct xlib_egl_driver
*xdrv
= xlib_egl_driver(drv
);
534 struct xlib_egl_surface
*surf
;
535 __GLcontextModes visual
;
537 EGLBoolean bind_texture
;
539 surf
= CALLOC_STRUCT(xlib_egl_surface
);
541 _eglError(EGL_BAD_ALLOC
, "eglCreatePbufferSurface");
545 if (!_eglInitSurface(drv
, &surf
->Base
, EGL_PBUFFER_BIT
,
546 conf
, attrib_list
)) {
550 if (surf
->Base
.Width
< 0 || surf
->Base
.Height
< 0) {
551 _eglError(EGL_BAD_PARAMETER
, "eglCreatePbufferSurface");
556 bind_texture
= (surf
->Base
.TextureFormat
!= EGL_NO_TEXTURE
);
557 width
= (uint
) surf
->Base
.Width
;
558 height
= (uint
) surf
->Base
.Height
;
559 if ((surf
->Base
.TextureTarget
== EGL_NO_TEXTURE
&& bind_texture
) ||
560 (surf
->Base
.TextureTarget
!= EGL_NO_TEXTURE
&& !bind_texture
)) {
561 _eglError(EGL_BAD_MATCH
, "eglCreatePbufferSurface");
565 /* a framebuffer of zero width or height confuses st */
566 if (width
== 0 || height
== 0) {
567 _eglError(EGL_BAD_MATCH
, "eglCreatePbufferSurface");
571 /* no mipmap generation */
572 if (surf
->Base
.MipmapTexture
) {
573 _eglError(EGL_BAD_MATCH
, "eglCreatePbufferSurface");
578 surf
->winsys
= xdrv
->winsys
;
580 _eglConfigToContextModesRec(conf
, &visual
);
582 /* Create GL statetracker framebuffer */
583 surf
->Framebuffer
= st_create_framebuffer(&visual
,
584 choose_color_format(&visual
),
585 choose_depth_format(&visual
),
586 choose_stencil_format(&visual
),
589 st_resize_framebuffer(surf
->Framebuffer
, width
, height
);
596 xlib_eglDestroySurface(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surface
)
598 struct xlib_egl_surface
*surf
= lookup_surface(surface
);
599 if (!_eglIsSurfaceBound(&surf
->Base
)) {
600 if (surf
->Base
.Type
!= EGL_PBUFFER_BIT
)
601 XFreeGC(surf
->Dpy
, surf
->Gc
);
602 st_unreference_framebuffer(surf
->Framebuffer
);
610 xlib_eglBindTexImage(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
611 _EGLSurface
*surface
, EGLint buffer
)
613 struct xlib_egl_surface
*xsurf
= lookup_surface(surface
);
614 struct xlib_egl_context
*xctx
;
615 struct pipe_surface
*psurf
;
616 enum pipe_format format
;
619 if (!xsurf
|| xsurf
->Base
.Type
!= EGL_PBUFFER_BIT
)
620 return _eglError(EGL_BAD_SURFACE
, "eglBindTexImage");
621 if (buffer
!= EGL_BACK_BUFFER
)
622 return _eglError(EGL_BAD_PARAMETER
, "eglBindTexImage");
623 if (xsurf
->Base
.BoundToTexture
)
624 return _eglError(EGL_BAD_ACCESS
, "eglBindTexImage");
626 /* this should be updated when choose_color_format is */
627 switch (xsurf
->Base
.TextureFormat
) {
628 case EGL_TEXTURE_RGB
:
629 format
= PIPE_FORMAT_R8G8B8_UNORM
;
631 case EGL_TEXTURE_RGBA
:
632 format
= PIPE_FORMAT_A8R8G8B8_UNORM
;
635 return _eglError(EGL_BAD_MATCH
, "eglBindTexImage");
638 switch (xsurf
->Base
.TextureTarget
) {
640 target
= ST_TEXTURE_2D
;
643 return _eglError(EGL_BAD_MATCH
, "eglBindTexImage");
647 if (eglGetCurrentSurface(EGL_DRAW
) == surface
) {
648 xctx
= lookup_context(_eglGetCurrentContext());
649 st_flush(xctx
->Context
, PIPE_FLUSH_RENDER_CACHE
| PIPE_FLUSH_FRAME
,
652 else if (_eglIsSurfaceBound(&xsurf
->Base
)) {
653 xctx
= lookup_context(xsurf
->Base
.Binding
);
655 st_finish(xctx
->Context
);
658 st_get_framebuffer_surface(xsurf
->Framebuffer
, ST_SURFACE_BACK_LEFT
,
660 st_bind_texture_surface(psurf
, target
, xsurf
->Base
.MipmapLevel
, format
);
661 xsurf
->Base
.BoundToTexture
= EGL_TRUE
;
668 xlib_eglReleaseTexImage(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*surface
,
671 struct xlib_egl_surface
*xsurf
= lookup_surface(surface
);
672 struct pipe_surface
*psurf
;
674 if (!xsurf
|| xsurf
->Base
.Type
!= EGL_PBUFFER_BIT
||
675 !xsurf
->Base
.BoundToTexture
)
676 return _eglError(EGL_BAD_SURFACE
, "eglReleaseTexImage");
677 if (buffer
!= EGL_BACK_BUFFER
)
678 return _eglError(EGL_BAD_PARAMETER
, "eglReleaseTexImage");
680 st_get_framebuffer_surface(xsurf
->Framebuffer
, ST_SURFACE_BACK_LEFT
,
682 st_unbind_texture_surface(psurf
, ST_TEXTURE_2D
, xsurf
->Base
.MipmapLevel
);
683 xsurf
->Base
.BoundToTexture
= EGL_FALSE
;
690 xlib_eglSwapBuffers(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*draw
)
692 /* error checking step: */
693 if (!_eglSwapBuffers(drv
, dpy
, draw
))
697 struct xlib_egl_surface
*xsurf
= lookup_surface(draw
);
698 struct pipe_winsys
*pws
= xsurf
->winsys
;
699 struct pipe_surface
*psurf
;
701 st_get_framebuffer_surface(xsurf
->Framebuffer
, ST_SURFACE_BACK_LEFT
,
704 st_notify_swapbuffers(xsurf
->Framebuffer
);
706 display_surface(pws
, psurf
, xsurf
);
708 check_and_update_buffer_size(xsurf
);
716 * Determine which API(s) is(are) present by looking for some specific
720 find_supported_apis(void)
725 handle
= dlopen(NULL
, RTLD_LAZY
| RTLD_LOCAL
);
729 if (dlsym(handle
, "st_api_OpenGL_ES1"))
730 mask
|= EGL_OPENGL_ES_BIT
;
732 if (dlsym(handle
, "st_api_OpenGL_ES2"))
733 mask
|= EGL_OPENGL_ES2_BIT
;
735 if (dlsym(handle
, "st_api_OpenGL"))
736 mask
|= EGL_OPENGL_BIT
;
738 if (dlsym(handle
, "st_api_OpenVG"))
739 mask
|= EGL_OPENVG_BIT
;
748 * This is the main entrypoint into the driver.
749 * Called by libEGL to instantiate an _EGLDriver object.
752 _eglMain(_EGLDisplay
*dpy
, const char *args
)
754 struct xlib_egl_driver
*xdrv
;
756 _eglLog(_EGL_INFO
, "Entering EGL/Xlib _eglMain(%s)", args
);
758 xdrv
= CALLOC_STRUCT(xlib_egl_driver
);
763 dpy
->Xdpy
= XOpenDisplay(NULL
);
766 _eglInitDriverFallbacks(&xdrv
->Base
);
767 xdrv
->Base
.API
.Initialize
= xlib_eglInitialize
;
768 xdrv
->Base
.API
.Terminate
= xlib_eglTerminate
;
769 xdrv
->Base
.API
.GetProcAddress
= xlib_eglGetProcAddress
;
770 xdrv
->Base
.API
.CreateContext
= xlib_eglCreateContext
;
771 xdrv
->Base
.API
.DestroyContext
= xlib_eglDestroyContext
;
772 xdrv
->Base
.API
.CreateWindowSurface
= xlib_eglCreateWindowSurface
;
773 xdrv
->Base
.API
.CreatePbufferSurface
= xlib_eglCreatePbufferSurface
;
774 xdrv
->Base
.API
.DestroySurface
= xlib_eglDestroySurface
;
775 xdrv
->Base
.API
.BindTexImage
= xlib_eglBindTexImage
;
776 xdrv
->Base
.API
.ReleaseTexImage
= xlib_eglReleaseTexImage
;
777 xdrv
->Base
.API
.MakeCurrent
= xlib_eglMakeCurrent
;
778 xdrv
->Base
.API
.SwapBuffers
= xlib_eglSwapBuffers
;
780 xdrv
->Base
.ClientAPIsMask
= find_supported_apis();
781 if (xdrv
->Base
.ClientAPIsMask
== 0x0) {
782 /* the app isn't directly linked with any EGL-supprted APIs
783 * (such as libGLESv2.so) so use an EGL utility to see what
784 * APIs might be loaded dynamically on this system.
786 xdrv
->Base
.ClientAPIsMask
= _eglFindAPIs();
789 xdrv
->Base
.Name
= "Xlib/softpipe";
791 /* create one winsys and use it for all contexts/surfaces */
792 xdrv
->winsys
= create_sw_winsys();
793 xdrv
->winsys
->flush_frontbuffer
= flush_frontbuffer
;
795 xdrv
->screen
= softpipe_create_screen(xdrv
->winsys
);