diff options
author | Kristian Høgsberg <[email protected]> | 2010-05-02 10:17:07 -0400 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2010-05-02 10:17:07 -0400 |
commit | 0870e4a2022cff79805613ae7cd4b9237a2f564c (patch) | |
tree | 694d0c07918661996255cff226602045e0d9c707 /src/mesa/drivers/dri/common | |
parent | 9d3360567346036f1c2b0b5e9de9bd123d883762 (diff) | |
parent | 9fd5fa05122aa0cac0051fa92d1634bde43209db (diff) |
Merge branch 'gles2-2'
Conflicts:
src/mesa/drivers/dri/common/dri_util.h
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 |
2 files changed, 60 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index d2ffa5da642..360c5247548 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 0fe6f1e246c..ab6c6e57afc 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 |