Is this method better than reworking dri_util.c? I still had to
replace some XF86DRIxxx calls in dri_util.c. There needs to be some
way to replace the __glxXX calls in the dispatch table. Right now I'm
using an #ifdef but it can't stay that way.
Both schemes have merit. I probably like the first scheme of doing the
glx_find_dri_screen() call before you get into dri_util. Then change
things like driCreateNewContext to take __DRIscreen* instead of
Display/scrn.
My EGL porgram run on DRI now but I'm not getting any drawing output.
I must still have something messed up in the buffer
pointers/stride/whatever.
--
Jon Smirl
[EMAIL PROTECTED]
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -72,6 +72,26 @@ static void * DriverCreateContextWrapper
Display *dpy, XVisualInfo *vis, void *shared, __DRIcontext *ctx,
const __GLcontextModes *fbconfig, int render_type );
+GLboolean __glXCreateContextWithConfig(__DRInativeDisplay* dpy, int screen,
+ int configID, void* context, drm_context_t * hHWContext);
+
+GLboolean __glXCreateDrawable( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable, drm_drawable_t * hHWDrawable );
+
+GLboolean __glXDestroyDrawable( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable );
+
+GLboolean __glXDestroyContext( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable );
+
+GLboolean __glXGetDrawableInfo(__DRInativeDisplay * ndpy, int screen,
__DRIid drawable,
+ unsigned int* index, unsigned int* stamp,
+ int* X, int* Y, int* W, int* H,
+ int* numClipRects, drm_clip_rect_t ** pClipRects,
+ int* backX, int* backY,
+ int* numBackClipRects, drm_clip_rect_t ** pBackClipRects );
+
+
#ifndef DRI_NEW_INTERFACE_ONLY
static Bool dummyBindContext2( Display *dpy, int scrn,
GLXDrawable draw, GLXDrawable read, GLXContext gc );
@@ -2926,8 +2946,11 @@ static const struct name_address_pair GL
GLX_FUNCTION( __glXFindDRIScreen ),
GLX_FUNCTION( __glXGetInternalVersion ),
GLX_FUNCTION( __glXWindowExists ),
- GLX_FUNCTION2( __glXCreateContextWithConfig,
XF86DRICreateContextWithConfig ),
- GLX_FUNCTION2( __glXGetDrawableInfo, XF86DRIGetDrawableInfo ),
+ GLX_FUNCTION( __glXCreateContextWithConfig ),
+ GLX_FUNCTION( __glXCreateDrawable ),
+ GLX_FUNCTION( __glXDestroyDrawable ),
+ GLX_FUNCTION( __glXDestroyContext ),
+ GLX_FUNCTION( __glXGetDrawableInfo ),
/*** DRI configuration ***/
GLX_FUNCTION( glXGetScreenDriver ),
@@ -3057,7 +3080,7 @@ int __glXGetInternalVersion(void)
}
-
+#ifndef EGL_DRI
static Bool windowExistsFlag;
static int windowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
@@ -3067,7 +3090,7 @@ static int windowExistsErrorHandler(Disp
}
return 0;
}
-
+#endif
/**
* Determine if a window associated with a \c GLXDrawable exists on the
* X-server. This function is not used internally by libGL. It is provided
@@ -3087,6 +3110,12 @@ static int windowExistsErrorHandler(Disp
*
* \since Internal API version 20021128.
*/
+#ifdef EGL_DRI
+static Bool __glXWindowExists(Display *dpy, GLXDrawable draw)
+{
+ return GL_TRUE;
+}
+#else
static Bool __glXWindowExists(Display *dpy, GLXDrawable draw)
{
XWindowAttributes xwa;
@@ -3099,7 +3128,7 @@ static Bool __glXWindowExists(Display *d
XSetErrorHandler(oldXErrorHandler);
return windowExistsFlag;
}
-
+#endif
/**
* Get the unadjusted system time (UST). Currently, the UST is measured in
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -65,6 +65,9 @@
#include <sys/mman.h>
#include "xf86dri.h"
#include "sarea.h"
+#ifdef EGL_DRI
+#include "egldri.h"
+#endif
#include "dri_glx.h"
#endif
@@ -1508,17 +1511,61 @@ GLXDrawable glXGetCurrentDrawable(void)
/************************************************************************/
#ifdef GLX_DIRECT_RENDERING
+#ifdef EGL_DRI
/* Return the DRI per screen structure */
-__DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn)
+__DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *ndpy, int scrn)
+{
+ driDisplay *disp = (driDisplay *)ndpy;
+ return &disp->driScreen;
+}
+GLboolean __glXCreateContextWithConfig(__DRInativeDisplay* ndpy, int
screen, int configID, void* context, drm_context_t * hHWContext)
+{
+ return GL_TRUE;
+}
+GLboolean __glXCreateDrawable( __DRInativeDisplay * ndpy, int screen,
__DRIid drawable, drm_drawable_t * hHWDrawable )
+{
+ return GL_TRUE;
+}
+GLboolean __glXDestroyDrawable( __DRInativeDisplay * ndpy, int
screen, __DRIid drawable )
+{
+ return GL_TRUE;
+}
+GLboolean __glXDestroyContext( __DRInativeDisplay * ndpy, int screen,
__DRIid context )
+{
+ return GL_TRUE;
+}
+GLboolean __glXGetDrawableInfo(__DRInativeDisplay * ndpy, int screen,
__DRIid drawable,
+ unsigned int* index, unsigned int* stamp,
+ int* X, int* Y, int* W, int* H,
+ int* numClipRects, drm_clip_rect_t ** pClipRects,
+ int* backX, int* backY,
+ int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
+{
+ driSurface *surf = Lookup_driSurface(drawable);
+
+ *X = 0;
+ *Y = 0;
+ *W = surf->Base.Width;
+ *H = surf->Base.Height;
+
+ *numClipRects = 1;
+ *pClipRects = malloc(sizeof(**pClipRects));
+ **pClipRects = (drm_clip_rect_t){0, 0, surf->Base.Width, surf->Base.Height};
+
+ return GL_TRUE;
+}
+#else
+/* Return the DRI per screen structure */
+__DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *ndpy, int scrn)
{
__DRIscreen *pDRIScreen = NULL;
- XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ XExtDisplayInfo *info = __glXFindDisplay(ndpy);
XExtData **privList, *found;
__GLXdisplayPrivate *dpyPriv;
XEDataObject dataObj;
__glXLock();
- dataObj.display = dpy;
+ dataObj.display = ndpy;
privList = XEHeadOfExtensionList(dataObj);
found = XFindOnExtensionList(privList, info->codes->extension);
__glXUnlock();
@@ -1530,6 +1577,33 @@ __DRIscreen *__glXFindDRIScreen(__DRInat
return pDRIScreen;
}
+GLboolean __glXCreateContextWithConfig(__DRInativeDisplay* ndpy, int
screen, int configID, void* context, drm_context_t * hHWContext)
+{
+ return XF86DRICreateContextWithConfig(ndpy, screen, configID,
context, hHWContext);
+}
+GLboolean __glXCreateDrawable( __DRInativeDisplay * ndpy, int screen,
__DRIid drawable, drm_drawable_t * hHWDrawable )
+{
+ return XF86DRICreateDrawable( ndpy, screen, drawable, hHWDrawable );
+}
+GLboolean __glXDestroyDrawable( __DRInativeDisplay * ndpy, int
screen, __DRIid drawable )
+{
+ return XF86DRIDestroyDrawable(ndpy, screen, drawable);
+}
+GLboolean __glXDestroyContext( __DRInativeDisplay * ndpy, int screen,
__DRIid context )
+{
+ return XF86DRIDestroyContext(ndpy, screen, drawable);
+}
+GLboolean __glXGetDrawableInfo(__DRInativeDisplay * ndpy, int screen,
__DRIid drawable,
+ unsigned int* index, unsigned int* stamp,
+ int* X, int* Y, int* W, int* H,
+ int* numClipRects, drm_clip_rect_t ** pClipRects,
+ int* backX, int* backY,
+ int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
+{
+ return XF86DRIGetDrawableInfo(ndpy, screen, drawable, index,
stamp, X, Y, W, H,
+ numClipRects, pClipRects, backX, backY,
numBackClipRects, pBackClipRects );
+}
+#endif
#endif
/************************************************************************/
diff --git a/src/mesa/drivers/dri/common/dri_util.c
b/src/mesa/drivers/dri/common/dri_util.c
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -82,6 +82,18 @@ typedef GLboolean (*PFNGLXCREATECONTEXTW
static PFNGLXCREATECONTEXTWITHCONFIGPROC create_context_with_config;
+typedef GLboolean (*PFNGLXCREATEDRAWABLE)( __DRInativeDisplay*, int,
__DRIid, drm_context_t * );
+
+static PFNGLXCREATEDRAWABLE create_drawable;
+
+typedef GLboolean (*PFNGLXDESTROYDRAWABLE)( __DRInativeDisplay*, int, __DRIid);
+
+static PFNGLXDESTROYDRAWABLE destroy_drawable;
+
+typedef GLboolean (*PFNGLXDESTROYCONTEXT)( __DRInativeDisplay*, int, __DRIid);
+
+static PFNGLXDESTROYCONTEXT destroy_context;
+
/**
* Cached copy of the internal API version used by libGL and the client-side
* DRI driver.
@@ -824,7 +836,7 @@ static void *driCreateNewDrawable(__DRIn
return NULL;
}
- if (!XF86DRICreateDrawable(dpy, modes->screen, draw, &pdp->hHWDrawable)) {
+ if (!create_drawable(dpy, modes->screen, draw, &pdp->hHWDrawable)) {
_mesa_free(pdp);
return NULL;
}
@@ -854,7 +866,7 @@ static void *driCreateNewDrawable(__DRIn
glXGetProcAddress( (const GLubyte *) "__glXGetDrawableInfo" );
if ( pdp->getInfo == NULL ) {
#ifdef DRI_NEW_INTERFACE_ONLY
- (void)XF86DRIDestroyDrawable(dpy, modes->screen, pdp->draw);
+ (void)destroy_drawable(dpy, modes->screen, pdp->draw);
_mesa_free(pdp);
return NULL;
#else
@@ -864,7 +876,7 @@ static void *driCreateNewDrawable(__DRIn
if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, modes,
renderType == GLX_PIXMAP_BIT)) {
- (void)XF86DRIDestroyDrawable(dpy, modes->screen, pdp->draw);
+ (void)destroy_drawable(dpy, modes->screen, pdp->draw);
_mesa_free(pdp);
return NULL;
}
@@ -922,7 +934,7 @@ static void driDestroyDrawable(__DRInati
if (pdp) {
(*psp->DriverAPI.DestroyBuffer)(pdp);
if ((*window_exists)(dpy, pdp->draw))
- (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
+ (void)destroy_drawable(dpy, scrn, pdp->draw);
if (pdp->pClipRects) {
_mesa_free(pdp->pClipRects);
pdp->pClipRects = NULL;
@@ -961,7 +973,7 @@ static void driDestroyContext(__DRInativ
if (pcp) {
(*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp);
__driGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
- (void)XF86DRIDestroyContext(dpy, scrn, pcp->contextID);
+ (void)destroy_context(dpy, scrn, pcp->contextID);
_mesa_free(pcp);
}
}
@@ -1242,6 +1254,30 @@ __driUtilCreateNewScreen(__DRInativeDisp
#endif /* DRI_NEW_INTERFACE_ONLY */
}
+ create_drawable = (PFNGLXCREATEDRAWABLE)
+ glXGetProcAddress( (const GLubyte *) "__glXCreateDrawable" );
+ if ( create_drawable == NULL ) {
+ fprintf( stderr, "libGL error: libGL.so version (%08u) is too old. "
+ "20050713 or later is required.\n", internal_api_version );
+ return NULL;
+ }
+
+ destroy_drawable = (PFNGLXDESTROYDRAWABLE)
+ glXGetProcAddress( (const GLubyte *) "__glXDestroyDrawable" );
+ if ( destroy_drawable == NULL ) {
+ fprintf( stderr, "libGL error: libGL.so version (%08u) is too old. "
+ "20050713 or later is required.\n", internal_api_version );
+ return NULL;
+ }
+
+ destroy_context = (PFNGLXDESTROYCONTEXT)
+ glXGetProcAddress( (const GLubyte *) "__glXDestroyDrawable" );
+ if ( destroy_context == NULL ) {
+ fprintf( stderr, "libGL error: libGL.so version (%08u) is too old. "
+ "20050713 or later is required.\n", internal_api_version );
+ return NULL;
+ }
+
api_ver = internal_api_version;
psp = (__DRIscreenPrivate *)_mesa_malloc(sizeof(__DRIscreenPrivate));
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel