aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/drivers/dri
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-11-07 07:15:44 +0100
committermarha <marha@users.sourceforge.net>2011-11-07 07:15:44 +0100
commit1ed503a856d9753a813951796bc6ba56c42ecd28 (patch)
tree9bd4e360a04dcb4b17d5ed3ac7e11b7225e5c4c2 /mesalib/src/mesa/drivers/dri
parent02f377d5e2dd18537d0807ad63675a0970b5a37d (diff)
downloadvcxsrv-1ed503a856d9753a813951796bc6ba56c42ecd28.tar.gz
vcxsrv-1ed503a856d9753a813951796bc6ba56c42ecd28.tar.bz2
vcxsrv-1ed503a856d9753a813951796bc6ba56c42ecd28.zip
xserver pixman mesa git update 7 nov 2011
Diffstat (limited to 'mesalib/src/mesa/drivers/dri')
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.c533
-rw-r--r--mesalib/src/mesa/drivers/dri/common/dri_util.h201
-rw-r--r--mesalib/src/mesa/drivers/dri/common/drisw_util.c49
-rw-r--r--mesalib/src/mesa/drivers/dri/common/drisw_util.h134
-rw-r--r--mesalib/src/mesa/drivers/dri/common/utils.c23
-rw-r--r--mesalib/src/mesa/drivers/dri/common/utils.h5
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.c22
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h2
8 files changed, 382 insertions, 587 deletions
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index da4e39f9c..1640c1448 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -15,12 +15,7 @@
*/
-#include <assert.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "main/imports.h"
-
+#include <xf86drm.h>
#include "dri_util.h"
#include "utils.h"
#include "xmlpool.h"
@@ -35,18 +30,230 @@ PUBLIC const char __dri2ConfigOptions[] =
static const uint __dri2NConfigOptions = 1;
-#ifndef GLX_OML_sync_control
-typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *drawable, int32_t *numerator, int32_t *denominator);
-#endif
+/*****************************************************************/
+/** \name Screen handling functions */
+/*****************************************************************/
+/*@{*/
+
+static void
+setupLoaderExtensions(__DRIscreen *psp,
+ const __DRIextension **extensions)
+{
+ int i;
+
+ for (i = 0; extensions[i]; i++) {
+ if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0)
+ psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_IMAGE_LOOKUP) == 0)
+ psp->dri2.image = (__DRIimageLookupExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_USE_INVALIDATE) == 0)
+ psp->dri2.useInvalidate = (__DRIuseInvalidateExtension *) extensions[i];
+ }
+}
+
+static __DRIscreen *
+dri2CreateNewScreen(int scrn, int fd,
+ const __DRIextension **extensions,
+ const __DRIconfig ***driver_configs, void *data)
+{
+ static const __DRIextension *emptyExtensionList[] = { NULL };
+ __DRIscreen *psp;
+ drmVersionPtr version;
+
+ psp = calloc(1, sizeof(*psp));
+ if (!psp)
+ return NULL;
+
+ setupLoaderExtensions(psp, extensions);
+
+ version = drmGetVersion(fd);
+ if (version) {
+ psp->drm_version.major = version->version_major;
+ psp->drm_version.minor = version->version_minor;
+ psp->drm_version.patch = version->version_patchlevel;
+ drmFreeVersion(version);
+ }
+
+ psp->loaderPrivate = data;
+
+ psp->extensions = emptyExtensionList;
+ psp->fd = fd;
+ psp->myNum = scrn;
+
+ psp->api_mask = (1 << __DRI_API_OPENGL);
+
+ *driver_configs = driDriverAPI.InitScreen(psp);
+ if (*driver_configs == NULL) {
+ free(psp);
+ return NULL;
+ }
+
+ driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions, __dri2NConfigOptions);
+ driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2");
+
+ return psp;
+}
+
+/**
+ * Destroy the per-screen private information.
+ *
+ * \internal
+ * This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls
+ * drmClose(), and finally frees \p screenPrivate.
+ */
+static void driDestroyScreen(__DRIscreen *psp)
+{
+ if (psp) {
+ /* No interaction with the X-server is possible at this point. This
+ * routine is called after XCloseDisplay, so there is no protocol
+ * stream open to the X-server anymore.
+ */
+
+ _mesa_destroy_shader_compiler();
+
+ driDriverAPI.DestroyScreen(psp);
+
+ driDestroyOptionCache(&psp->optionCache);
+ driDestroyOptionInfo(&psp->optionInfo);
+
+ free(psp);
+ }
+}
+
+static const __DRIextension **driGetExtensions(__DRIscreen *psp)
+{
+ return psp->extensions;
+}
+
+/*@}*/
+
+
+/*****************************************************************/
+/** \name Context handling functions */
+/*****************************************************************/
+/*@{*/
+
+static __DRIcontext *
+dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
+ const __DRIconfig *config,
+ __DRIcontext *shared, void *data)
+{
+ __DRIcontext *context;
+ const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
+ void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
+ gl_api mesa_api;
+
+ if (!(screen->api_mask & (1 << api)))
+ return NULL;
+
+ switch (api) {
+ case __DRI_API_OPENGL:
+ mesa_api = API_OPENGL;
+ break;
+ case __DRI_API_GLES:
+ mesa_api = API_OPENGLES;
+ break;
+ case __DRI_API_GLES2:
+ mesa_api = API_OPENGLES2;
+ break;
+ default:
+ return NULL;
+ }
+
+ context = malloc(sizeof *context);
+ if (!context)
+ return NULL;
+
+ context->loaderPrivate = data;
+
+ context->driScreenPriv = screen;
+ context->driDrawablePriv = NULL;
+ context->driReadablePriv = NULL;
+
+ if (!driDriverAPI.CreateContext(mesa_api, modes, context, shareCtx) ) {
+ free(context);
+ return NULL;
+ }
+
+ return context;
+}
+
+
+static __DRIcontext *
+dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
+ __DRIcontext *shared, void *data)
+{
+ return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL,
+ config, shared, data);
+}
+
+/**
+ * Destroy the per-context private information.
+ *
+ * \internal
+ * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls
+ * drmDestroyContext(), and finally frees \p contextPrivate.
+ */
+static void
+driDestroyContext(__DRIcontext *pcp)
+{
+ if (pcp) {
+ driDriverAPI.DestroyContext(pcp);
+ free(pcp);
+ }
+}
+
+static int
+driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask)
+{
+ (void) dest;
+ (void) src;
+ (void) mask;
+ return GL_FALSE;
+}
+
+/*@}*/
-static void dri_get_drawable(__DRIdrawable *pdp);
-static void dri_put_drawable(__DRIdrawable *pdp);
/*****************************************************************/
/** \name Context (un)binding functions */
/*****************************************************************/
/*@{*/
+static void dri_get_drawable(__DRIdrawable *pdp);
+static void dri_put_drawable(__DRIdrawable *pdp);
+
+/**
+ * This function takes both a read buffer and a draw buffer. This is needed
+ * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent
+ * function.
+ */
+static int driBindContext(__DRIcontext *pcp,
+ __DRIdrawable *pdp,
+ __DRIdrawable *prp)
+{
+ /*
+ ** Assume error checking is done properly in glXMakeCurrent before
+ ** calling driUnbindContext.
+ */
+
+ if (!pcp)
+ return GL_FALSE;
+
+ /* Bind the drawable to the context */
+ pcp->driDrawablePriv = pdp;
+ pcp->driReadablePriv = prp;
+ if (pdp) {
+ pdp->driContextPriv = pcp;
+ dri_get_drawable(pdp);
+ }
+ if (prp && pdp != prp) {
+ dri_get_drawable(prp);
+ }
+
+ return driDriverAPI.MakeCurrent(pcp, pdp, prp);
+}
+
/**
* Unbind context.
*
@@ -65,7 +272,6 @@ static void dri_put_drawable(__DRIdrawable *pdp);
*/
static int driUnbindContext(__DRIcontext *pcp)
{
- __DRIscreen *psp;
__DRIdrawable *pdp;
__DRIdrawable *prp;
@@ -75,17 +281,16 @@ static int driUnbindContext(__DRIcontext *pcp)
*/
if (pcp == NULL)
- return GL_FALSE;
+ return GL_FALSE;
- psp = pcp->driScreenPriv;
pdp = pcp->driDrawablePriv;
prp = pcp->driReadablePriv;
/* already unbound */
if (!pdp && !prp)
- return GL_TRUE;
- /* Let driver unbind drawable from context */
- (*psp->DriverAPI.UnbindContext)(pcp);
+ return GL_TRUE;
+
+ driDriverAPI.UnbindContext(pcp);
assert(pdp);
if (pdp->refcount == 0) {
@@ -96,63 +301,48 @@ static int driUnbindContext(__DRIcontext *pcp)
dri_put_drawable(pdp);
if (prp != pdp) {
- if (prp->refcount == 0) {
+ if (prp->refcount == 0) {
/* ERROR!!! */
return GL_FALSE;
}
- dri_put_drawable(prp);
+ dri_put_drawable(prp);
}
-
/* XXX this is disabled so that if we call SwapBuffers on an unbound
* window we can determine the last context bound to the window and
* use that context's lock. (BrianP, 2-Dec-2000)
*/
- pcp->driDrawablePriv = pcp->driReadablePriv = NULL;
+ pcp->driDrawablePriv = NULL;
+ pcp->driReadablePriv = NULL;
return GL_TRUE;
}
-/**
- * This function takes both a read buffer and a draw buffer. This is needed
- * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent
- * function.
- */
-static int driBindContext(__DRIcontext *pcp,
- __DRIdrawable *pdp,
- __DRIdrawable *prp)
-{
- __DRIscreen *psp = NULL;
+/*@}*/
- /*
- ** Assume error checking is done properly in glXMakeCurrent before
- ** calling driUnbindContext.
- */
- if (!pcp)
- return GL_FALSE;
+static void dri_get_drawable(__DRIdrawable *pdp)
+{
+ pdp->refcount++;
+}
- /* Bind the drawable to the context */
- psp = pcp->driScreenPriv;
- pcp->driDrawablePriv = pdp;
- pcp->driReadablePriv = prp;
+static void dri_put_drawable(__DRIdrawable *pdp)
+{
if (pdp) {
- pdp->driContextPriv = pcp;
- dri_get_drawable(pdp);
- }
- if (prp && pdp != prp) {
- dri_get_drawable(prp);
- }
+ pdp->refcount--;
+ if (pdp->refcount)
+ return;
- /* Call device-specific MakeCurrent */
- return (*psp->DriverAPI.MakeCurrent)(pcp, pdp, prp);
+ driDriverAPI.DestroyBuffer(pdp);
+ free(pdp);
+ }
}
static __DRIdrawable *
dri2CreateNewDrawable(__DRIscreen *screen,
const __DRIconfig *config,
- void *loaderPrivate)
+ void *data)
{
__DRIdrawable *pdraw;
@@ -160,15 +350,18 @@ dri2CreateNewDrawable(__DRIscreen *screen,
if (!pdraw)
return NULL;
+ pdraw->loaderPrivate = data;
+
+ pdraw->driScreenPriv = screen;
pdraw->driContextPriv = NULL;
- pdraw->loaderPrivate = loaderPrivate;
- pdraw->refcount = 1;
+ pdraw->refcount = 0;
pdraw->lastStamp = 0;
pdraw->w = 0;
pdraw->h = 0;
- pdraw->driScreenPriv = screen;
- if (!(*screen->DriverAPI.CreateBuffer)(screen, pdraw, &config->modes, 0)) {
+ dri_get_drawable(pdraw);
+
+ if (!driDriverAPI.CreateBuffer(screen, pdraw, &config->modes, GL_FALSE)) {
free(pdraw);
return NULL;
}
@@ -178,19 +371,25 @@ dri2CreateNewDrawable(__DRIscreen *screen,
return pdraw;
}
+static void
+driDestroyDrawable(__DRIdrawable *pdp)
+{
+ dri_put_drawable(pdp);
+}
+
static __DRIbuffer *
dri2AllocateBuffer(__DRIscreen *screen,
unsigned int attachment, unsigned int format,
int width, int height)
{
- return (*screen->DriverAPI.AllocateBuffer)(screen, attachment, format,
- width, height);
+ return driDriverAPI.AllocateBuffer(screen, attachment, format,
+ width, height);
}
static void
dri2ReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
{
- (*screen->DriverAPI.ReleaseBuffer)(screen, buffer);
+ driDriverAPI.ReleaseBuffer(screen, buffer);
}
@@ -228,232 +427,12 @@ dri2ConfigQueryf(__DRIscreen *screen, const char *var, GLfloat *val)
return 0;
}
-
-static void dri_get_drawable(__DRIdrawable *pdp)
-{
- pdp->refcount++;
-}
-
-static void dri_put_drawable(__DRIdrawable *pdp)
-{
- __DRIscreen *psp;
-
- if (pdp) {
- pdp->refcount--;
- if (pdp->refcount)
- return;
-
- psp = pdp->driScreenPriv;
- (*psp->DriverAPI.DestroyBuffer)(pdp);
- free(pdp);
- }
-}
-
-static void
-driDestroyDrawable(__DRIdrawable *pdp)
-{
- dri_put_drawable(pdp);
-}
-
-/*@}*/
-
-
-/*****************************************************************/
-/** \name Context handling functions */
-/*****************************************************************/
-/*@{*/
-
-/**
- * Destroy the per-context private information.
- *
- * \internal
- * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls
- * drmDestroyContext(), and finally frees \p contextPrivate.
- */
-static void
-driDestroyContext(__DRIcontext *pcp)
-{
- if (pcp) {
- (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp);
- free(pcp);
- }
-}
-
static unsigned int
dri2GetAPIMask(__DRIscreen *screen)
{
return screen->api_mask;
}
-static __DRIcontext *
-dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
- const __DRIconfig *config,
- __DRIcontext *shared, void *data)
-{
- __DRIcontext *context;
- const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
- void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
- gl_api mesa_api;
-
- if (!(screen->api_mask & (1 << api)))
- return NULL;
-
- switch (api) {
- case __DRI_API_OPENGL:
- mesa_api = API_OPENGL;
- break;
- case __DRI_API_GLES:
- mesa_api = API_OPENGLES;
- break;
- case __DRI_API_GLES2:
- mesa_api = API_OPENGLES2;
- break;
- default:
- return NULL;
- }
-
- context = malloc(sizeof *context);
- if (!context)
- return NULL;
-
- context->driScreenPriv = screen;
- context->driDrawablePriv = NULL;
- context->loaderPrivate = data;
-
- if (!(*screen->DriverAPI.CreateContext)(mesa_api, modes,
- context, shareCtx) ) {
- free(context);
- return NULL;
- }
-
- return context;
-}
-
-
-static __DRIcontext *
-dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
- __DRIcontext *shared, void *data)
-{
- return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL,
- config, shared, data);
-}
-
-static int
-driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask)
-{
- (void) dest;
- (void) src;
- (void) mask;
- return GL_FALSE;
-}
-
-/*@}*/
-
-
-/*****************************************************************/
-/** \name Screen handling functions */
-/*****************************************************************/
-/*@{*/
-
-/**
- * Destroy the per-screen private information.
- *
- * \internal
- * This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls
- * drmClose(), and finally frees \p screenPrivate.
- */
-static void driDestroyScreen(__DRIscreen *psp)
-{
- if (psp) {
- /* No interaction with the X-server is possible at this point. This
- * routine is called after XCloseDisplay, so there is no protocol
- * stream open to the X-server anymore.
- */
-
- _mesa_destroy_shader_compiler();
-
- if (psp->DriverAPI.DestroyScreen)
- (*psp->DriverAPI.DestroyScreen)(psp);
-
- driDestroyOptionCache(&psp->optionCache);
- driDestroyOptionInfo(&psp->optionInfo);
-
- free(psp);
- }
-}
-
-static void
-setupLoaderExtensions(__DRIscreen *psp,
- const __DRIextension **extensions)
-{
- int i;
-
- for (i = 0; extensions[i]; i++) {
- if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0)
- psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i];
- if (strcmp(extensions[i]->name, __DRI_IMAGE_LOOKUP) == 0)
- psp->dri2.image = (__DRIimageLookupExtension *) extensions[i];
- if (strcmp(extensions[i]->name, __DRI_USE_INVALIDATE) == 0)
- psp->dri2.useInvalidate = (__DRIuseInvalidateExtension *) extensions[i];
- }
-}
-
-/**
- * DRI2
- */
-static __DRIscreen *
-dri2CreateNewScreen(int scrn, int fd,
- const __DRIextension **extensions,
- const __DRIconfig ***driver_configs, void *data)
-{
- static const __DRIextension *emptyExtensionList[] = { NULL };
- __DRIscreen *psp;
- drmVersionPtr version;
-
- if (driDriverAPI.InitScreen2 == NULL)
- return NULL;
-
- psp = calloc(1, sizeof(*psp));
- if (!psp)
- return NULL;
-
- setupLoaderExtensions(psp, extensions);
-
- version = drmGetVersion(fd);
- if (version) {
- psp->drm_version.major = version->version_major;
- psp->drm_version.minor = version->version_minor;
- psp->drm_version.patch = version->version_patchlevel;
- drmFreeVersion(version);
- }
-
- psp->extensions = emptyExtensionList;
- psp->fd = fd;
- psp->myNum = scrn;
-
- psp->DriverAPI = driDriverAPI;
- psp->api_mask = (1 << __DRI_API_OPENGL);
- *driver_configs = driDriverAPI.InitScreen2(psp);
- if (*driver_configs == NULL) {
- free(psp);
- return NULL;
- }
-
- psp->DriverAPI = driDriverAPI;
- psp->loaderPrivate = data;
-
- driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions,
- __dri2NConfigOptions);
- driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum,
- "dri2");
-
- return psp;
-}
-
-static const __DRIextension **driGetExtensions(__DRIscreen *psp)
-{
- return psp->extensions;
-}
/** Core interface */
const __DRIcoreExtension driCoreExtension = {
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.h b/mesalib/src/mesa/drivers/dri/common/dri_util.h
index 7a3b0a9b2..bebb021f6 100644
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.h
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.h
@@ -44,24 +44,25 @@
* \author Brian Paul <brian@precisioninsight.com>
*/
+/**
+ * The following structs are shared between DRISW and DRI2, the DRISW structs
+ * are essentially base classes of the DRI2 structs. DRISW needs to compile on
+ * platforms without DRM, so keep the structs opaque to DRM.
+ */
+
#ifndef _DRI_UTIL_H_
#define _DRI_UTIL_H_
#include <GL/gl.h>
-#include <drm.h>
-#include <drm_sarea.h>
-#include <xf86drm.h>
-#include "xmlconfig.h"
-#include "main/glheader.h"
+#include <GL/internal/dri_interface.h>
#include "main/mtypes.h"
-#include "GL/internal/dri_interface.h"
-
-#define GLX_BAD_CONTEXT 5
+#include "xmlconfig.h"
/**
* Extensions.
*/
extern const __DRIcoreExtension driCoreExtension;
+extern const __DRIswrastExtension driSWRastExtension;
extern const __DRIdri2Extension driDRI2Extension;
extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
@@ -76,56 +77,37 @@ extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
* this structure.
*/
struct __DriverAPIRec {
- /**
- * Screen destruction callback
- */
+ const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
+
void (*DestroyScreen)(__DRIscreen *driScrnPriv);
- /**
- * Context creation callback
- */
GLboolean (*CreateContext)(gl_api api,
- const struct gl_config *glVis,
- __DRIcontext *driContextPriv,
+ const struct gl_config *glVis,
+ __DRIcontext *driContextPriv,
void *sharedContextPrivate);
- /**
- * Context destruction callback
- */
void (*DestroyContext)(__DRIcontext *driContextPriv);
- /**
- * Buffer (drawable) creation callback
- */
GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
__DRIdrawable *driDrawPriv,
const struct gl_config *glVis,
GLboolean pixmapBuffer);
-
- /**
- * Buffer (drawable) destruction callback
- */
+
void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
- /**
- * Context activation callback
- */
+ void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
+
GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
__DRIdrawable *driDrawPriv,
__DRIdrawable *driReadPriv);
- /**
- * Context unbinding callback
- */
GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
- /* DRI2 Entry point */
- const __DRIconfig **(*InitScreen2) (__DRIscreen * priv);
-
__DRIbuffer *(*AllocateBuffer) (__DRIscreen *screenPrivate,
- unsigned int attachment,
- unsigned int format,
- int width, int height);
+ unsigned int attachment,
+ unsigned int format,
+ int width, int height);
+
void (*ReleaseBuffer) (__DRIscreen *screenPrivate, __DRIbuffer *buffer);
};
@@ -133,59 +115,54 @@ extern const struct __DriverAPIRec driDriverAPI;
/**
- * Per-drawable private DRI driver information.
+ * Per-screen private driver information.
*/
-struct __DRIdrawableRec {
+struct __DRIscreenRec {
/**
- * Driver's private drawable information.
- *
- * This structure is opaque.
+ * Current screen's number
*/
- void *driverPrivate;
+ int myNum;
/**
- * Private data from the loader. We just hold on to it and pass
- * it back when calling into loader provided functions.
+ * File descriptor returned when the kernel device driver is opened.
+ *
+ * Used to:
+ * - authenticate client to kernel
+ * - map the frame buffer, SAREA, etc.
+ * - close the kernel device driver
*/
- void *loaderPrivate;
+ int fd;
/**
- * Reference count for number of context's currently bound to this
- * drawable.
- *
- * Once it reaches zero, the drawable can be destroyed.
- *
- * \note This behavior will change with GLX 1.3.
+ * DRM (kernel module) version information.
*/
- int refcount;
+ __DRIversion drm_version;
/**
- * Last value of the stamp.
- *
- * If this differs from the value stored at __DRIdrawable::dri2.stamp,
- * then the drawable information has been modified by the X server, and the
- * drawable information (below) should be retrieved from the X server.
+ * Device-dependent private information (not stored in the SAREA).
+ *
+ * This pointer is never touched by the DRI layer.
*/
- unsigned int lastStamp;
+ void *driverPrivate;
- int w, h;
+ void *loaderPrivate;
- /**
- * Pointer to context to which this drawable is currently bound.
- */
- __DRIcontext *driContextPriv;
+ const __DRIextension **extensions;
- /**
- * Pointer to screen on which this drawable was created.
- */
- __DRIscreen *driScreenPriv;
+ const __DRIswrastLoaderExtension *swrast_loader;
- /**
- * Drawable timestamp. Increased when the loader calls invalidate.
- */
struct {
- unsigned int stamp;
+ /* Flag to indicate that this is a DRI2 screen. Many of the above
+ * fields will not be valid or initializaed in that case. */
+ __DRIdri2LoaderExtension *loader;
+ __DRIimageLookupExtension *image;
+ __DRIuseInvalidateExtension *useInvalidate;
} dri2;
+
+ driOptionCache optionInfo;
+ driOptionCache optionCache;
+
+ unsigned int api_mask;
};
/**
@@ -198,6 +175,11 @@ struct __DRIcontextRec {
void *driverPrivate;
/**
+ * The loaders's private context data. This structure is opaque.
+ */
+ void *loaderPrivate;
+
+ /**
* Pointer to drawable currently bound to this context for drawing.
*/
__DRIdrawable *driDrawablePriv;
@@ -212,11 +194,6 @@ struct __DRIcontextRec {
*/
__DRIscreen *driScreenPriv;
- /**
- * The loaders's private context data. This structure is opaque.
- */
- void *loaderPrivate;
-
struct {
int draw_stamp;
int read_stamp;
@@ -224,59 +201,59 @@ struct __DRIcontextRec {
};
/**
- * Per-screen private driver information.
+ * Per-drawable private DRI driver information.
*/
-struct __DRIscreenRec {
+struct __DRIdrawableRec {
/**
- * Current screen's number
+ * Driver's private drawable information.
+ *
+ * This structure is opaque.
*/
- int myNum;
+ void *driverPrivate;
/**
- * Callback functions into the hardware-specific DRI driver code.
+ * Private data from the loader. We just hold on to it and pass
+ * it back when calling into loader provided functions.
*/
- struct __DriverAPIRec DriverAPI;
+ void *loaderPrivate;
- const __DRIextension **extensions;
+ /**
+ * Pointer to context to which this drawable is currently bound.
+ */
+ __DRIcontext *driContextPriv;
/**
- * DRM (kernel module) version information.
+ * Pointer to screen on which this drawable was created.
*/
- __DRIversion drm_version;
+ __DRIscreen *driScreenPriv;
/**
- * File descriptor returned when the kernel device driver is opened.
- *
- * Used to:
- * - authenticate client to kernel
- * - map the frame buffer, SAREA, etc.
- * - close the kernel device driver
+ * Reference count for number of context's currently bound to this
+ * drawable.
+ *
+ * Once it reaches zero, the drawable can be destroyed.
+ *
+ * \note This behavior will change with GLX 1.3.
*/
- int fd;
+ int refcount;
/**
- * Device-dependent private information (not stored in the SAREA).
- *
- * This pointer is never touched by the DRI layer.
+ * Last value of the stamp.
+ *
+ * If this differs from the value stored at __DRIdrawable::dri2.stamp,
+ * then the drawable information has been modified by the X server, and the
+ * drawable information (below) should be retrieved from the X server.
*/
-#ifdef __cplusplus
- void *priv;
-#else
- void *private;
-#endif
+ unsigned int lastStamp;
+ int w, h;
+
+ /**
+ * Drawable timestamp. Increased when the loader calls invalidate.
+ */
struct {
- /* Flag to indicate that this is a DRI2 screen. Many of the above
- * fields will not be valid or initializaed in that case. */
- __DRIdri2LoaderExtension *loader;
- __DRIimageLookupExtension *image;
- __DRIuseInvalidateExtension *useInvalidate;
+ unsigned int stamp;
} dri2;
-
- driOptionCache optionInfo;
- driOptionCache optionCache;
- unsigned int api_mask;
- void *loaderPrivate;
};
extern void
diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.c b/mesalib/src/mesa/drivers/dri/common/drisw_util.c
index 1bdb6d893..614339eeb 100644
--- a/mesalib/src/mesa/drivers/dri/common/drisw_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/drisw_util.c
@@ -27,7 +27,7 @@
* DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits.
*/
-#include "drisw_util.h"
+#include "dri_util.h"
#include "utils.h"
@@ -54,20 +54,19 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions,
static const __DRIextension *emptyExtensionList[] = { NULL };
__DRIscreen *psp;
- (void) data;
-
psp = CALLOC_STRUCT(__DRIscreenRec);
if (!psp)
return NULL;
setupLoaderExtensions(psp, extensions);
+ psp->loaderPrivate = data;
+
psp->extensions = emptyExtensionList;
psp->fd = -1;
psp->myNum = scrn;
*driver_configs = driDriverAPI.InitScreen(psp);
-
if (*driver_configs == NULL) {
FREE(psp);
return NULL;
@@ -80,7 +79,6 @@ static void driDestroyScreen(__DRIscreen *psp)
{
if (psp) {
driDriverAPI.DestroyScreen(psp);
-
FREE(psp);
}
}
@@ -96,37 +94,12 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp)
*/
static __DRIcontext *
-driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
- __DRIcontext *shared, void *data)
-{
- __DRIcontext *pcp;
- void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
-
- pcp = CALLOC_STRUCT(__DRIcontextRec);
- if (!pcp)
- return NULL;
-
- pcp->loaderPrivate = data;
-
- pcp->driScreenPriv = psp;
- pcp->driDrawablePriv = NULL;
- pcp->driReadablePriv = NULL;
-
- if (!driDriverAPI.CreateContext(API_OPENGL,
- &config->modes, pcp, shareCtx)) {
- FREE(pcp);
- return NULL;
- }
-
- return pcp;
-}
-
-static __DRIcontext *
driCreateNewContextForAPI(__DRIscreen *psp, int api,
const __DRIconfig *config,
__DRIcontext *shared, void *data)
{
__DRIcontext *pcp;
+ const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
gl_api mesa_api;
@@ -154,8 +127,7 @@ driCreateNewContextForAPI(__DRIscreen *psp, int api,
pcp->driDrawablePriv = NULL;
pcp->driReadablePriv = NULL;
- if (!driDriverAPI.CreateContext(mesa_api,
- &config->modes, pcp, shareCtx)) {
+ if (!driDriverAPI.CreateContext(mesa_api, modes, pcp, shareCtx)) {
FREE(pcp);
return NULL;
}
@@ -163,6 +135,14 @@ driCreateNewContextForAPI(__DRIscreen *psp, int api,
return pcp;
}
+static __DRIcontext *
+driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
+ __DRIcontext *shared, void *data)
+{
+ return driCreateNewContextForAPI(psp, __DRI_API_OPENGL,
+ config, shared, data);
+}
+
static void
driDestroyContext(__DRIcontext *pcp)
{
@@ -193,7 +173,7 @@ static int driBindContext(__DRIcontext *pcp,
pdp->driContextPriv = pcp;
dri_get_drawable(pdp);
}
- if ( prp && pdp != prp ) {
+ if (prp && pdp != prp) {
dri_get_drawable(prp);
}
}
@@ -248,7 +228,6 @@ static void dri_put_drawable(__DRIdrawable *pdp)
return;
driDriverAPI.DestroyBuffer(pdp);
-
FREE(pdp);
}
}
diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.h b/mesalib/src/mesa/drivers/dri/common/drisw_util.h
deleted file mode 100644
index cae47e1f6..000000000
--- a/mesalib/src/mesa/drivers/dri/common/drisw_util.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * @file
- * Binding of the DRI interface (dri_interface.h) for DRISW.
- *
- * The DRISW structs are 'base classes' of the corresponding DRI1 / DRI2 (DRM)
- * structs. The bindings for SW and DRM can be unified by making the DRM structs
- * 'sub-classes' of the SW structs, either proper or with field re-ordering.
- *
- * The code can also be unified but that requires cluttering the common code
- * with ifdef's and guarding with (__DRIscreen::fd >= 0) for DRM.
- */
-
-#ifndef _DRISW_UTIL_H
-#define _DRISW_UTIL_H
-
-#include "main/mtypes.h"
-
-#include <GL/gl.h>
-#include <GL/internal/dri_interface.h>
-typedef struct _drmLock drmLock;
-
-
-/**
- * Extensions
- */
-extern const __DRIcoreExtension driCoreExtension;
-extern const __DRIswrastExtension driSWRastExtension;
-
-
-/**
- * Driver callback functions
- */
-struct __DriverAPIRec {
- const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
-
- void (*DestroyScreen)(__DRIscreen *driScrnPriv);
-
- GLboolean (*CreateContext)(gl_api glapi,
- const struct gl_config *glVis,
- __DRIcontext *driContextPriv,
- void *sharedContextPrivate);
-
- void (*DestroyContext)(__DRIcontext *driContextPriv);
-
- GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
- __DRIdrawable *driDrawPriv,
- const struct gl_config *glVis,
- GLboolean pixmapBuffer);
-
- void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
-
- void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
-
- GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
- __DRIdrawable *driDrawPriv,
- __DRIdrawable *driReadPriv);
-
- GLboolean (*UnbindContext)(__DRIcontext *driContextPriv);
-};
-
-extern const struct __DriverAPIRec driDriverAPI;
-
-
-/**
- * Data types
- */
-struct __DRIscreenRec {
- int myNum;
-
- int fd;
-
- void *private;
-
- const __DRIextension **extensions;
-
- const __DRIswrastLoaderExtension *swrast_loader;
-};
-
-struct __DRIcontextRec {
-
- void *driverPrivate;
-
- void *loaderPrivate;
-
- __DRIdrawable *driDrawablePriv;
-
- __DRIdrawable *driReadablePriv;
-
- __DRIscreen *driScreenPriv;
-};
-
-struct __DRIdrawableRec {
-
- void *driverPrivate;
-
- void *loaderPrivate;
-
- __DRIcontext *driContextPriv;
-
- __DRIscreen *driScreenPriv;
-
- int refcount;
-
- /* gallium */
- unsigned int lastStamp;
-
- int w;
- int h;
-};
-
-#endif /* _DRISW_UTIL_H */
diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c
index d8656a784..328f56b50 100644
--- a/mesalib/src/mesa/drivers/dri/common/utils.c
+++ b/mesalib/src/mesa/drivers/dri/common/utils.c
@@ -37,29 +37,6 @@
#include "utils.h"
-/**
- * Print message to \c stderr if the \c LIBGL_DEBUG environment variable
- * is set.
- *
- * Is called from the drivers.
- *
- * \param f \c printf like format string.
- */
-void
-__driUtilMessage(const char *f, ...)
-{
- va_list args;
-
- if (getenv("LIBGL_DEBUG")) {
- fprintf(stderr, "libGL: ");
- va_start(args, f);
- vfprintf(stderr, f, args);
- va_end(args);
- fprintf(stderr, "\n");
- }
-}
-
-
unsigned
driParseDebugString( const char * debug,
const struct dri_debug_control * control )
diff --git a/mesalib/src/mesa/drivers/dri/common/utils.h b/mesalib/src/mesa/drivers/dri/common/utils.h
index c2302de5d..9d6eb3037 100644
--- a/mesalib/src/mesa/drivers/dri/common/utils.h
+++ b/mesalib/src/mesa/drivers/dri/common/utils.h
@@ -32,16 +32,11 @@
#include <GL/internal/dri_interface.h>
#include "main/context.h"
-typedef struct __DRIutilversionRec2 __DRIutilversion2;
-
struct dri_debug_control {
const char * string;
unsigned flag;
};
-extern void
-__driUtilMessage(const char *f, ...);
-
extern unsigned driParseDebugString( const char * debug,
const struct dri_debug_control * control );
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
index 12dd31bb1..6d1d5ec61 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
@@ -420,6 +420,28 @@ static GLboolean checkValue (const driOptionValue *v, const driOptionInfo *info)
return GL_FALSE;
}
+/**
+ * Print message to \c stderr if the \c LIBGL_DEBUG environment variable
+ * is set.
+ *
+ * Is called from the drivers.
+ *
+ * \param f \c printf like format string.
+ */
+static void
+__driUtilMessage(const char *f, ...)
+{
+ va_list args;
+
+ if (getenv("LIBGL_DEBUG")) {
+ fprintf(stderr, "libGL: ");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ fprintf(stderr, "\n");
+ }
+}
+
/** \brief Output a warning message. */
#define XML_WARNING1(msg) do {\
__driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h
index 50e6a83d5..b57012aef 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h
@@ -30,7 +30,7 @@
#include <GL/gl.h>
#include <GL/internal/dri_interface.h>
#include "main/mtypes.h"
-#include "drisw_util.h"
+#include "dri_util.h"
/**