* constructors for DRI2.
*/
#define __DRI_DRI2 "DRI_DRI2"
-#define __DRI_DRI2_VERSION 1
+#define __DRI_DRI2_VERSION 2
+
+#define __DRI_API_OPENGL 0
+#define __DRI_API_GLES 1
+#define __DRI_API_GLES2 2
struct __DRIdri2ExtensionRec {
__DRIextension base;
__DRIcontext *shared,
void *loaderPrivate);
+ /* Since version 2 */
+ unsigned int (*getAPIMask)(__DRIscreen *screen);
+
+ __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
+ int api,
+ const __DRIconfig *config,
+ __DRIcontext *shared,
+ void *data);
};
pcp->hHWContext = hwContext;
- if ( !(*psp->DriverAPI.CreateContext)(&config->modes, pcp, shareCtx) ) {
+ if ( !(*psp->DriverAPI.CreateContext)(API_OPENGL,
+ &config->modes, pcp, shareCtx) ) {
free(pcp);
return NULL;
}
return 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;
+ 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;
+ }
+
+ context = malloc(sizeof *context);
+ if (!context)
+ return NULL;
+
+ context->driScreenPriv = screen;
+ context->driDrawablePriv = NULL;
+ context->loaderPrivate = data;
+
+ if (!(*screen->DriverAPI.CreateContext)(api, &config->modes,
+ context, shareCtx) ) {
+ free(context);
+ return NULL;
+ }
+
+ return context;
+}
+
static __DRIcontext *
dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
__DRIcontext *shared, void *data)
{
- return driCreateNewContext(screen, config, 0, shared, 0, data);
+ return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL,
+ config, shared, data);
}
-
static int
driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask)
{
psp->dri2.enabled = GL_FALSE;
psp->DriverAPI = driDriverAPI;
+ psp->api_mask = (1 << __DRI_API_OPENGL);
*driver_modes = driDriverAPI.InitScreen(psp);
if (*driver_modes == NULL) {
psp->dri2.enabled = GL_TRUE;
psp->DriverAPI = driDriverAPI;
+ psp->api_mask = (1 << __DRI_API_OPENGL);
*driver_configs = driDriverAPI.InitScreen2(psp);
if (*driver_configs == NULL) {
free(psp);
dri2CreateNewScreen,
dri2CreateNewDrawable,
dri2CreateNewContext,
+ dri2GetAPIMask,
+ dri2CreateNewContextForAPI
};
static int
#include <drm_sarea.h>
#include <xf86drm.h>
#include "main/glheader.h"
+#include "main/mtypes.h"
#include "GL/internal/glcore.h"
#include "GL/internal/dri_interface.h"
/**
* Context creation callback
*/
- GLboolean (*CreateContext)(const __GLcontextModes *glVis,
- __DRIcontext *driContextPriv,
+ GLboolean (*CreateContext)(gl_api api,
+ const __GLcontextModes *glVis,
+ __DRIcontext *driContextPriv,
void *sharedContextPrivate);
/**
/* The lock actually in use, old sarea or DRI2 */
drmLock *lock;
+
+ unsigned int api_mask;
};
extern void
};
GLboolean
-i810CreateContext( const __GLcontextModes *mesaVis,
+i810CreateContext( gl_api api,
+ const __GLcontextModes *mesaVis,
__DRIcontext *driContextPriv,
void *sharedContextPrivate )
{
extern GLboolean
-i810CreateContext( const __GLcontextModes *mesaVis,
+i810CreateContext( gl_api api,
+ const __GLcontextModes *mesaVis,
__DRIcontext *driContextPriv,
void *sharedContextPrivate );
void *sharedContextPrivate);
static GLboolean
-intelCreateContext(const __GLcontextModes * mesaVis,
+intelCreateContext(gl_api api,
+ const __GLcontextModes * mesaVis,
__DRIcontext * driContextPriv,
void *sharedContextPrivate)
{
/* Create the device specific context.
*/
-GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
+GLboolean mach64CreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate )
{
#define MACH64_CONTEXT(ctx) ((mach64ContextPtr)(ctx->DriverCtx))
-extern GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
+extern GLboolean mach64CreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate );
static GLboolean
-mgaCreateContext( const __GLcontextModes *mesaVis,
+mgaCreateContext( gl_api api,
+ const __GLcontextModes *mesaVis,
__DRIcontext *driContextPriv,
void *sharedContextPrivate )
{
}
GLboolean
-nouveau_context_create(const __GLcontextModes *visual, __DRIcontext *dri_ctx,
+nouveau_context_create(gl_api api,
+ const __GLcontextModes *visual, __DRIcontext *dri_ctx,
void *share_ctx)
{
__DRIscreen *dri_screen = dri_ctx->driScreenPriv;
/* Create the device specific context.
*/
-GLboolean r128CreateContext( const __GLcontextModes *glVisual,
+GLboolean r128CreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate )
{
(rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_MOBILITY)
-extern GLboolean r128CreateContext( const __GLcontextModes *glVisual,
+extern GLboolean r128CreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate );
/* Create the device specific rendering context.
*/
-GLboolean r200CreateContext( const __GLcontextModes *glVisual,
+GLboolean r200CreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate)
{
extern void r200DestroyContext( __DRIcontext *driContextPriv );
-extern GLboolean r200CreateContext( const __GLcontextModes *glVisual,
+extern GLboolean r200CreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate);
extern GLboolean r200MakeCurrent( __DRIcontext *driContextPriv,
/* Create the device specific rendering context.
*/
-GLboolean r300CreateContext(const __GLcontextModes * glVisual,
+GLboolean r300CreateContext(gl_api api,
+ const __GLcontextModes * glVisual,
__DRIcontext * driContextPriv,
void *sharedContextPrivate)
{
#define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx))
extern void r300DestroyContext(__DRIcontext * driContextPriv);
-extern GLboolean r300CreateContext(const __GLcontextModes * glVisual,
+extern GLboolean r300CreateContext(gl_api api,
+ const __GLcontextModes * glVisual,
__DRIcontext * driContextPriv,
void *sharedContextPrivate);
/* Create the device specific rendering context.
*/
-GLboolean r600CreateContext(const __GLcontextModes * glVisual,
+GLboolean r600CreateContext(gl_api api,
+ const __GLcontextModes * glVisual,
__DRIcontext * driContextPriv,
void *sharedContextPrivate)
{
#define R700_CONTEXT(ctx) ((context_t *)(ctx->DriverCtx))
#define GL_CONTEXT(context) ((GLcontext *)(context->radeon.glCtx))
-extern GLboolean r600CreateContext(const __GLcontextModes * glVisual,
+extern GLboolean r600CreateContext(gl_api api,
+ const __GLcontextModes * glVisual,
__DRIcontext * driContextPriv,
void *sharedContextPrivate);
/* Create the device specific context.
*/
GLboolean
-r100CreateContext( const __GLcontextModes *glVisual,
- __DRIcontext *driContextPriv,
- void *sharedContextPrivate)
+r100CreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
+ __DRIcontext *driContextPriv,
+ void *sharedContextPrivate)
{
__DRIscreen *sPriv = driContextPriv->driScreenPriv;
radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
#define RADEON_OLD_PACKETS 1
-extern GLboolean r100CreateContext( const __GLcontextModes *glVisual,
+extern GLboolean r100CreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate);
}
static GLboolean
-savageCreateContext( const __GLcontextModes *mesaVis,
+savageCreateContext( gl_api api,
+ const __GLcontextModes *mesaVis,
__DRIcontext *driContextPriv,
void *sharedContextPrivate )
{
}
GLboolean
-sisCreateContext( const __GLcontextModes *glVisual,
+sisCreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate )
{
VERBOSE_SIS_MEMORY = 0x2
};
-extern GLboolean sisCreateContext( const __GLcontextModes *glVisual,
+extern GLboolean sisCreateContext( gl_api api,
+ const __GLcontextModes *glVisual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate );
extern void sisDestroyContext( __DRIcontext * );
{ NULL, 0 }
};
-GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
+GLboolean tdfxCreateContext( gl_api api,
+ const __GLcontextModes *mesaVis,
__DRIcontext *driContextPriv,
void *sharedContextPrivate )
{
extern GLboolean
-tdfxCreateContext( const __GLcontextModes *mesaVis,
+tdfxCreateContext( gl_api api,
+ const __GLcontextModes *mesaVis,
__DRIcontext *driContextPriv,
void *sharedContextPrivate );
GLboolean
-viaCreateContext(const __GLcontextModes *visual,
+viaCreateContext(gl_api api,
+ const __GLcontextModes *visual,
__DRIcontext *driContextPriv,
void *sharedContextPrivate)
{
extern GLboolean
-viaCreateContext(const __GLcontextModes *mesaVis,
+viaCreateContext(gl_api api,
+ const __GLcontextModes *mesaVis,
__DRIcontext *driContextPriv,
void *sharedContextPrivate);