};
+/* XXX temp hack */
+static struct xdri_egl_driver *TheDriver = NULL;
+
+
/** cast wrapper */
static struct xdri_egl_driver *
xdri_egl_driver(_EGLDriver *drv)
+/** Get size of given window */
+static Status
+get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height)
+{
+ Window root;
+ Status stat;
+ int xpos, ypos;
+ unsigned int w, h, bw, depth;
+ stat = XGetGeometry(dpy, d, &root, &xpos, &ypos, &w, &h, &bw, &depth);
+ *width = w;
+ *height = h;
+ return stat;
+}
+
+
/**
* Produce a set of EGL configs.
* Note that we get the list of GLcontextModes from the GLX library.
static __DRIscreen *
dri_find_dri_screen(__DRInativeDisplay *ndpy, int scrn)
{
- /* unused? */
- return NULL;
+ assert(TheDriver);
+
+ return &TheDriver->driScreen;
}
static GLboolean
-dri_window_exists(__DRInativeDisplay *dpy, __DRIid draw)
+dri_window_exists(__DRInativeDisplay *ndpy, __DRIid draw)
{
return EGL_TRUE;
}
static GLboolean
-dri_create_context(__DRInativeDisplay *dpy, int screenNum, int configID,
+dri_create_context(__DRInativeDisplay *ndpy, int screenNum, int configID,
void * contextID, drm_context_t * hw_context)
{
assert(configID >= 0);
- return XF86DRICreateContextWithConfig(dpy, screenNum,
+ return XF86DRICreateContextWithConfig(ndpy, screenNum,
configID, contextID, hw_context);
}
static GLboolean
-dri_get_drawable_info(__DRInativeDisplay *dpy, int scrn,
+dri_get_drawable_info(__DRInativeDisplay *ndpy, int scrn,
__DRIid draw, unsigned int * index, unsigned int * stamp,
int * x, int * y, int * width, int * height,
int * numClipRects, drm_clip_rect_t ** pClipRects,
{
_eglLog(_EGL_DEBUG, "XDRI: %s", __FUNCTION__);
- if (!XF86DRIGetDrawableInfo(dpy, scrn, draw, index, stamp,
+ if (!XF86DRIGetDrawableInfo(ndpy, scrn, draw, index, stamp,
x, y, width, height,
numClipRects, pClipRects,
backX, backY,
char filename[100];
int flags = RTLD_NOW;
- snprintf(filename, sizeof(filename), "%s.so", xdri_drv->dri_driver_name);
+ /* try "egl_xxx_dri.so" first */
+ snprintf(filename, sizeof(filename), "egl_%s.so", xdri_drv->dri_driver_name);
_eglLog(_EGL_DEBUG, "XDRI: dlopen(%s)", filename);
-
xdri_drv->dri_driver_handle = dlopen(filename, flags);
- if (!xdri_drv->dri_driver_handle) {
- _eglLog(_EGL_WARNING, "XDRI Could not open %s (%s)",
- filename, dlerror());
+ if (xdri_drv->dri_driver_handle) {
+ _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s) OK", filename);
+ return EGL_TRUE;
+ }
+ else {
+ _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s) fail (%s)", filename, dlerror());
+ }
- return EGL_FALSE;
+ /* try regular "xxx_dri.so" next */
+ snprintf(filename, sizeof(filename), "%s.so", xdri_drv->dri_driver_name);
+ _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s)", filename);
+ xdri_drv->dri_driver_handle = dlopen(filename, flags);
+ if (xdri_drv->dri_driver_handle) {
+ _eglLog(_EGL_DEBUG, "XDRI: dlopen(%s) OK", filename);
+ return EGL_TRUE;
}
- return EGL_TRUE;
+
+ _eglLog(_EGL_WARNING, "XDRI Could not open %s (%s)", filename, dlerror());
+ return EGL_FALSE;
}
}
+static _EGLProc
+xdri_eglGetProcAddress(const char *procname)
+{
+#if 0
+ _EGLDriver *drv = NULL;
+
+ struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv);
+ /*_EGLDisplay *disp = _eglLookupDisplay(dpy);*/
+ _EGLProc *proc = xdri_drv->driScreen.getProcAddress(procname);
+ return proc;
+#elif 0
+ return (_EGLProc) st_get_proc_address(procname);
+#else
+ return NULL;
+#endif
+}
+
+
/**
* Called via eglCreateContext(), drv->API.CreateContext().
*/
_EGLDisplay *disp = _eglLookupDisplay(dpy);
struct xdri_egl_surface *xdri_surf;
int scrn = DefaultScreen(disp->Xdpy);
+ uint width, height;
xdri_surf = CALLOC_STRUCT(xdri_egl_surface);
if (!xdri_surf)
_eglSaveSurface(&xdri_surf->Base);
+ get_drawable_size(disp->Xdpy, window, &width, &height);
+ xdri_surf->Base.Width = width;
+ xdri_surf->Base.Height = height;
+
_eglLog(_EGL_DEBUG,
"XDRI: CreateWindowSurface win 0x%x handle %d hDrawable %d",
(int) window, _eglGetSurfaceHandle(&xdri_surf->Base),
{
struct xdri_egl_surface *xdri_surf = lookup_surface(draw);
- __GLXdisplayPrivate *priv = __glXInitialize(disp->Xdpy);
- __GLXscreenConfigs *scrn = priv->screenConfigs;
- __DRIscreen *psc = &scrn->driScreen;
+ struct xdri_egl_driver *xdri_drv = xdri_egl_driver(drv);
+ __DRIscreen *psc = &xdri_drv->driScreen;
__DRIdrawable * const pdraw = psc->getDrawable(disp->Xdpy,
xdri_surf->driDrawable,
psc->private);
if (!xdri_drv)
return NULL;
+ /* XXX temp hack */
+ TheDriver = xdri_drv;
+
_eglInitDriverFallbacks(&xdri_drv->Base);
xdri_drv->Base.API.Initialize = xdri_eglInitialize;
xdri_drv->Base.API.Terminate = xdri_eglTerminate;
+ xdri_drv->Base.API.GetProcAddress = xdri_eglGetProcAddress;
+
xdri_drv->Base.API.CreateContext = xdri_eglCreateContext;
xdri_drv->Base.API.MakeCurrent = xdri_eglMakeCurrent;
xdri_drv->Base.API.CreateWindowSurface = xdri_eglCreateWindowSurface;