6 #include "eglcontext.h"
7 #include "egldisplay.h"
9 #include "eglglobals.h"
12 #include "eglscreen.h"
13 #include "eglsurface.h"
16 const char *DefaultDriverName
= "demodriver";
20 * Choose and open/init the hardware driver for the given EGLDisplay.
21 * Previously, the EGLDisplay was created with _eglNewDisplay() where
22 * we recorded the user's NativeDisplayType parameter.
24 * Now we'll use the NativeDisplayType value.
26 * Currently, the native display value is treated as a string.
27 * If the first character is ':' we interpret it as a screen or card index
28 * number (i.e. ":0" or ":1", etc)
29 * Else if the first character is '!' we interpret it as specific driver name
30 * (i.e. "!r200" or "!i830".
33 _eglChooseDriver(EGLDisplay display
)
35 _EGLDisplay
*dpy
= _eglLookupDisplay(display
);
37 const char *driverName
= DefaultDriverName
;
46 else if (name
[0] == ':' && (name
[1] >= '0' && name
[1] <= '9') && !name
[2]) {
47 /* XXX probe hardware here to determine which driver to open */
48 driverName
= "libEGLdri";
50 else if (name
[0] == '!') {
51 /* use specified driver name */
52 driverName
= name
+ 1;
55 /* Maybe display was returned by XOpenDisplay? */
56 _eglLog(_EGL_FATAL
, "eglChooseDriver() bad name");
59 _eglLog(_EGL_INFO
, "eglChooseDriver() choosing %s", driverName
);
61 drv
= _eglOpenDriver(dpy
, driverName
);
69 * Open/load the named driver and call its bootstrap function: _eglMain().
70 * \return new _EGLDriver object.
73 _eglOpenDriver(_EGLDisplay
*dpy
, const char *driverName
)
78 char driverFilename
[1000];
80 /* XXX also prepend a directory path??? */
81 sprintf(driverFilename
, "%s.so", driverName
);
83 _eglLog(_EGL_DEBUG
, "dlopen(%s)", driverFilename
);
84 lib
= dlopen(driverFilename
, RTLD_NOW
);
86 _eglLog(_EGL_WARNING
, "Could not open %s (%s)",
87 driverFilename
, dlerror());
91 mainFunc
= (_EGLMain_t
) dlsym(lib
, "_eglMain");
93 _eglLog(_EGL_WARNING
, "_eglMain not found in %s", driverFilename
);
103 /* with a recurvise open you want the inner most handle */
105 drv
->LibHandle
= lib
;
115 _eglCloseDriver(_EGLDriver
*drv
, EGLDisplay dpy
)
117 void *handle
= drv
->LibHandle
;
120 _eglLog(_EGL_INFO
, "Closing driver");
123 * XXX check for currently bound context/surfaces and delete them?
126 b
= drv
->API
.Terminate(drv
, dpy
);
133 * Given a display handle, return the _EGLDriver for that display.
136 _eglLookupDriver(EGLDisplay dpy
)
138 _EGLDisplay
*d
= _eglLookupDisplay(dpy
);
147 * Plug all the available fallback routines into the given driver's
151 _eglInitDriverFallbacks(_EGLDriver
*drv
)
153 /* If a pointer is set to NULL, then the device driver _really_ has
156 drv
->API
.Initialize
= NULL
;
157 drv
->API
.Terminate
= NULL
;
159 drv
->API
.GetConfigs
= _eglGetConfigs
;
160 drv
->API
.ChooseConfig
= _eglChooseConfig
;
161 drv
->API
.GetConfigAttrib
= _eglGetConfigAttrib
;
163 drv
->API
.CreateContext
= _eglCreateContext
;
164 drv
->API
.DestroyContext
= _eglDestroyContext
;
165 drv
->API
.MakeCurrent
= _eglMakeCurrent
;
166 drv
->API
.QueryContext
= _eglQueryContext
;
168 drv
->API
.CreateWindowSurface
= _eglCreateWindowSurface
;
169 drv
->API
.CreatePixmapSurface
= _eglCreatePixmapSurface
;
170 drv
->API
.CreatePbufferSurface
= _eglCreatePbufferSurface
;
171 drv
->API
.DestroySurface
= _eglDestroySurface
;
172 drv
->API
.QuerySurface
= _eglQuerySurface
;
173 drv
->API
.SurfaceAttrib
= _eglSurfaceAttrib
;
174 drv
->API
.BindTexImage
= _eglBindTexImage
;
175 drv
->API
.ReleaseTexImage
= _eglReleaseTexImage
;
176 drv
->API
.SwapInterval
= _eglSwapInterval
;
177 drv
->API
.SwapBuffers
= _eglSwapBuffers
;
178 drv
->API
.CopyBuffers
= _eglCopyBuffers
;
180 drv
->API
.QueryString
= _eglQueryString
;
181 drv
->API
.WaitGL
= _eglWaitGL
;
182 drv
->API
.WaitNative
= _eglWaitNative
;
184 /* EGL_MESA_screen */
185 drv
->API
.ChooseModeMESA
= _eglChooseModeMESA
;
186 drv
->API
.GetModesMESA
= _eglGetModesMESA
;
187 drv
->API
.GetModeAttribMESA
= _eglGetModeAttribMESA
;
188 drv
->API
.GetScreensMESA
= _eglGetScreensMESA
;
189 drv
->API
.CreateScreenSurfaceMESA
= _eglCreateScreenSurfaceMESA
;
190 drv
->API
.ShowSurfaceMESA
= _eglShowSurfaceMESA
;
191 drv
->API
.ScreenPositionMESA
= _eglScreenPositionMESA
;
192 drv
->API
.QueryScreenMESA
= _eglQueryScreenMESA
;
193 drv
->API
.QueryScreenSurfaceMESA
= _eglQueryScreenSurfaceMESA
;
194 drv
->API
.QueryScreenModeMESA
= _eglQueryScreenModeMESA
;
195 drv
->API
.QueryModeStringMESA
= _eglQueryModeStringMESA
;
200 * Examine the individual extension enable/disable flags and recompute
201 * the driver's Extensions string.
204 UpdateExtensionsString(_EGLDriver
*drv
)
206 drv
->Extensions
[0] = 0;
208 if (drv
->MESA_screen_surface
)
209 strcat(drv
->Extensions
, "EGL_MESA_screen_surface ");
210 if (drv
->MESA_copy_context
)
211 strcat(drv
->Extensions
, "EGL_MESA_copy_context ");
212 assert(strlen(drv
->Extensions
) < MAX_EXTENSIONS_LEN
);
218 _eglQueryString(_EGLDriver
*drv
, EGLDisplay dpy
, EGLint name
)
224 return "Mesa Project";
228 UpdateExtensionsString(drv
);
229 return drv
->Extensions
;
231 _eglError(EGL_BAD_PARAMETER
, "eglQueryString");
238 _eglWaitGL(_EGLDriver
*drv
, EGLDisplay dpy
)
240 /* just a placeholder */
248 _eglWaitNative(_EGLDriver
*drv
, EGLDisplay dpy
, EGLint engine
)
250 /* just a placeholder */