diff options
Diffstat (limited to 'src/mesa/drivers/dri/common')
-rw-r--r-- | src/mesa/drivers/dri/common/dri_util.c | 58 | ||||
-rw-r--r-- | src/mesa/drivers/dri/common/dri_util.h | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/common/drisw_util.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/common/drisw_util.h | 5 |
4 files changed, 66 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index d2ffa5da64..360c524754 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -612,7 +612,8 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, 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; } @@ -620,15 +621,62 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, 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) { @@ -766,6 +814,7 @@ driCreateNewScreen(int scrn, psp->dri2.enabled = GL_FALSE; psp->DriverAPI = driDriverAPI; + psp->api_mask = (1 << __DRI_API_OPENGL); *driver_modes = driDriverAPI.InitScreen(psp); if (*driver_modes == NULL) { @@ -812,6 +861,7 @@ dri2CreateNewScreen(int scrn, int fd, 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); @@ -863,6 +913,8 @@ const __DRIdri2Extension driDRI2Extension = { dri2CreateNewScreen, dri2CreateNewDrawable, dri2CreateNewContext, + dri2GetAPIMask, + dri2CreateNewContextForAPI }; const __DRI2configQueryExtension dri2ConfigQueryExtension = { diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 0fe6f1e246..ab6c6e57af 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -53,6 +53,7 @@ #include <xf86drm.h> #include "xmlconfig.h" #include "main/glheader.h" +#include "main/mtypes.h" #include "GL/internal/glcore.h" #include "GL/internal/dri_interface.h" @@ -148,8 +149,9 @@ struct __DriverAPIRec { /** * Context creation callback */ - GLboolean (*CreateContext)(const __GLcontextModes *glVis, - __DRIcontext *driContextPriv, + GLboolean (*CreateContext)(gl_api api, + const __GLcontextModes *glVis, + __DRIcontext *driContextPriv, void *sharedContextPrivate); /** @@ -531,6 +533,7 @@ struct __DRIscreenRec { drmLock *lock; driOptionCache optionCache; + unsigned int api_mask; }; extern void diff --git a/src/mesa/drivers/dri/common/drisw_util.c b/src/mesa/drivers/dri/common/drisw_util.c index 8d08b93bfb..1529c23b16 100644 --- a/src/mesa/drivers/dri/common/drisw_util.c +++ b/src/mesa/drivers/dri/common/drisw_util.c @@ -112,7 +112,8 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, pcp->driDrawablePriv = NULL; pcp->driReadablePriv = NULL; - if (!driDriverAPI.CreateContext(&config->modes, pcp, shareCtx)) { + if (!driDriverAPI.CreateContext(API_OPENGL, + &config->modes, pcp, shareCtx)) { FREE(pcp); return NULL; } diff --git a/src/mesa/drivers/dri/common/drisw_util.h b/src/mesa/drivers/dri/common/drisw_util.h index 08d5a116e9..9c3d01c99c 100644 --- a/src/mesa/drivers/dri/common/drisw_util.h +++ b/src/mesa/drivers/dri/common/drisw_util.h @@ -36,6 +36,8 @@ #ifndef _DRISW_UTIL_H #define _DRISW_UTIL_H +#include "main/mtypes.h" + #include <GL/gl.h> #include <GL/internal/glcore.h> #include <GL/internal/dri_interface.h> @@ -57,7 +59,8 @@ struct __DriverAPIRec { void (*DestroyScreen)(__DRIscreen *driScrnPriv); - GLboolean (*CreateContext)(const __GLcontextModes *glVis, + GLboolean (*CreateContext)(gl_api glapi, + const __GLcontextModes *glVis, __DRIcontext *driContextPriv, void *sharedContextPrivate); |