From a7a9a91d7b28e5b5faed509d00f0f951e3136b1b Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 27 Apr 2010 11:04:51 -0400 Subject: dri: Add DRI entrypoints to create a context for a given API --- src/mesa/drivers/dri/common/dri_util.c | 58 ++++++++++++++++++++++++-- src/mesa/drivers/dri/common/dri_util.h | 8 +++- src/mesa/drivers/dri/i810/i810context.c | 3 +- src/mesa/drivers/dri/i810/i810screen.h | 3 +- src/mesa/drivers/dri/intel/intel_screen.c | 3 +- src/mesa/drivers/dri/mach64/mach64_context.c | 3 +- src/mesa/drivers/dri/mach64/mach64_context.h | 3 +- src/mesa/drivers/dri/mga/mga_xmesa.c | 3 +- src/mesa/drivers/dri/nouveau/nouveau_context.c | 3 +- src/mesa/drivers/dri/r128/r128_context.c | 3 +- src/mesa/drivers/dri/r128/r128_context.h | 3 +- src/mesa/drivers/dri/r200/r200_context.c | 3 +- src/mesa/drivers/dri/r200/r200_context.h | 3 +- src/mesa/drivers/dri/r300/r300_context.c | 3 +- src/mesa/drivers/dri/r300/r300_context.h | 3 +- src/mesa/drivers/dri/r600/r600_context.c | 3 +- src/mesa/drivers/dri/r600/r600_context.h | 3 +- src/mesa/drivers/dri/radeon/radeon_context.c | 7 ++-- src/mesa/drivers/dri/radeon/radeon_context.h | 3 +- src/mesa/drivers/dri/savage/savage_xmesa.c | 3 +- src/mesa/drivers/dri/sis/sis_context.c | 3 +- src/mesa/drivers/dri/sis/sis_context.h | 3 +- src/mesa/drivers/dri/tdfx/tdfx_context.c | 3 +- src/mesa/drivers/dri/tdfx/tdfx_context.h | 3 +- src/mesa/drivers/dri/unichrome/via_context.c | 3 +- src/mesa/drivers/dri/unichrome/via_screen.h | 3 +- 26 files changed, 111 insertions(+), 31 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index f1bbd38612..e08005f90b 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -564,7 +564,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; } @@ -572,15 +573,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) { @@ -718,6 +766,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) { @@ -763,6 +812,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); @@ -811,6 +861,8 @@ const __DRIdri2Extension driDRI2Extension = { dri2CreateNewScreen, dri2CreateNewDrawable, dri2CreateNewContext, + dri2GetAPIMask, + dri2CreateNewContextForAPI }; static int diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 038a81604f..4b7cd414b8 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -52,6 +52,7 @@ #include #include #include "main/glheader.h" +#include "main/mtypes.h" #include "GL/internal/glcore.h" #include "GL/internal/dri_interface.h" @@ -146,8 +147,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); /** @@ -527,6 +529,8 @@ struct __DRIscreenRec { /* The lock actually in use, old sarea or DRI2 */ drmLock *lock; + + unsigned int api_mask; }; extern void diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c index 34e34606b4..49f3ee88a6 100644 --- a/src/mesa/drivers/dri/i810/i810context.c +++ b/src/mesa/drivers/dri/i810/i810context.c @@ -166,7 +166,8 @@ static const struct dri_debug_control debug_control[] = }; GLboolean -i810CreateContext( const __GLcontextModes *mesaVis, +i810CreateContext( gl_api api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate ) { diff --git a/src/mesa/drivers/dri/i810/i810screen.h b/src/mesa/drivers/dri/i810/i810screen.h index 734e2fb002..fe6db7e6e1 100644 --- a/src/mesa/drivers/dri/i810/i810screen.h +++ b/src/mesa/drivers/dri/i810/i810screen.h @@ -78,7 +78,8 @@ typedef struct { extern GLboolean -i810CreateContext( const __GLcontextModes *mesaVis, +i810CreateContext( gl_api api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate ); diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 5e3f40836d..b27e7a34a7 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -364,7 +364,8 @@ extern GLboolean brwCreateContext(const __GLcontextModes * mesaVis, void *sharedContextPrivate); static GLboolean -intelCreateContext(const __GLcontextModes * mesaVis, +intelCreateContext(gl_api api, + const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate) { diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c index 77e7e53ce0..72a44d9642 100644 --- a/src/mesa/drivers/dri/mach64/mach64_context.c +++ b/src/mesa/drivers/dri/mach64/mach64_context.c @@ -86,7 +86,8 @@ static const struct dri_extension card_extensions[] = /* Create the device specific context. */ -GLboolean mach64CreateContext( const __GLcontextModes *glVisual, +GLboolean mach64CreateContext( gl_api api, + const __GLcontextModes *glVisual, __DRIcontext *driContextPriv, void *sharedContextPrivate ) { diff --git a/src/mesa/drivers/dri/mach64/mach64_context.h b/src/mesa/drivers/dri/mach64/mach64_context.h index 18fc859d01..893fc8daee 100644 --- a/src/mesa/drivers/dri/mach64/mach64_context.h +++ b/src/mesa/drivers/dri/mach64/mach64_context.h @@ -273,7 +273,8 @@ struct mach64_context { #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 ); diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index 687412bca5..31007ccb1d 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -423,7 +423,8 @@ static const struct dri_debug_control debug_control[] = static GLboolean -mgaCreateContext( const __GLcontextModes *mesaVis, +mgaCreateContext( gl_api api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate ) { diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 42bec659d7..f481161d46 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -75,7 +75,8 @@ nouveau_channel_flush_notify(struct nouveau_channel *chan) } 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; diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c index 67e9240505..7860708383 100644 --- a/src/mesa/drivers/dri/r128/r128_context.c +++ b/src/mesa/drivers/dri/r128/r128_context.c @@ -99,7 +99,8 @@ static const struct dri_debug_control debug_control[] = /* Create the device specific context. */ -GLboolean r128CreateContext( const __GLcontextModes *glVisual, +GLboolean r128CreateContext( gl_api api, + const __GLcontextModes *glVisual, __DRIcontext *driContextPriv, void *sharedContextPrivate ) { diff --git a/src/mesa/drivers/dri/r128/r128_context.h b/src/mesa/drivers/dri/r128/r128_context.h index 65f845c115..65ddb3bd23 100644 --- a/src/mesa/drivers/dri/r128/r128_context.h +++ b/src/mesa/drivers/dri/r128/r128_context.h @@ -224,7 +224,8 @@ struct r128_context { (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 ); diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index 36a29350cc..5896296021 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -271,7 +271,8 @@ static void r200_init_vtbl(radeonContextPtr radeon) /* Create the device specific rendering context. */ -GLboolean r200CreateContext( const __GLcontextModes *glVisual, +GLboolean r200CreateContext( gl_api api, + const __GLcontextModes *glVisual, __DRIcontext *driContextPriv, void *sharedContextPrivate) { diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h index a9dce310ae..305958f5d7 100644 --- a/src/mesa/drivers/dri/r200/r200_context.h +++ b/src/mesa/drivers/dri/r200/r200_context.h @@ -637,7 +637,8 @@ struct r200_context { 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, diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 4dce454c3a..6992ca59db 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -478,7 +478,8 @@ static void r300InitIoctlFuncs(struct dd_function_table *functions) /* Create the device specific rendering context. */ -GLboolean r300CreateContext(const __GLcontextModes * glVisual, +GLboolean r300CreateContext(gl_api api, + const __GLcontextModes * glVisual, __DRIcontext * driContextPriv, void *sharedContextPrivate) { diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index df7115e7da..fbb609b9f6 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -543,7 +543,8 @@ struct r300_context { #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); diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index fddac2f9bd..9f8923f09d 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -353,7 +353,8 @@ static void r600InitGLExtensions(GLcontext *ctx) /* Create the device specific rendering context. */ -GLboolean r600CreateContext(const __GLcontextModes * glVisual, +GLboolean r600CreateContext(gl_api api, + const __GLcontextModes * glVisual, __DRIcontext * driContextPriv, void *sharedContextPrivate) { diff --git a/src/mesa/drivers/dri/r600/r600_context.h b/src/mesa/drivers/dri/r600/r600_context.h index 72c8c869b7..063dd7c49a 100644 --- a/src/mesa/drivers/dri/r600/r600_context.h +++ b/src/mesa/drivers/dri/r600/r600_context.h @@ -155,7 +155,8 @@ struct r600_context { #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); diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 56aba16e9e..ee65d7ff3d 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -206,9 +206,10 @@ static void r100_init_vtbl(radeonContextPtr radeon) /* 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); diff --git a/src/mesa/drivers/dri/radeon/radeon_context.h b/src/mesa/drivers/dri/radeon/radeon_context.h index d84760bf74..c4bfbfdaeb 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_context.h @@ -450,7 +450,8 @@ struct r100_context { #define RADEON_OLD_PACKETS 1 -extern GLboolean r100CreateContext( const __GLcontextModes *glVisual, +extern GLboolean r100CreateContext( gl_api api, + const __GLcontextModes *glVisual, __DRIcontext *driContextPriv, void *sharedContextPrivate); diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index c3a53ea5e2..cbdc9c87ee 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -288,7 +288,8 @@ savageDestroyScreen(__DRIscreen *sPriv) } static GLboolean -savageCreateContext( const __GLcontextModes *mesaVis, +savageCreateContext( gl_api api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate ) { diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c index 400681a04a..85f26a08b7 100644 --- a/src/mesa/drivers/dri/sis/sis_context.c +++ b/src/mesa/drivers/dri/sis/sis_context.c @@ -158,7 +158,8 @@ void sisReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer, } GLboolean -sisCreateContext( const __GLcontextModes *glVisual, +sisCreateContext( gl_api api, + const __GLcontextModes *glVisual, __DRIcontext *driContextPriv, void *sharedContextPrivate ) { diff --git a/src/mesa/drivers/dri/sis/sis_context.h b/src/mesa/drivers/dri/sis/sis_context.h index 4179ee081a..132cee33ee 100644 --- a/src/mesa/drivers/dri/sis/sis_context.h +++ b/src/mesa/drivers/dri/sis/sis_context.h @@ -438,7 +438,8 @@ enum _sis_verbose { 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 * ); diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c index edb1875f76..c30fcf3a6f 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_context.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c @@ -164,7 +164,8 @@ static const struct dri_debug_control debug_control[] = { NULL, 0 } }; -GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis, +GLboolean tdfxCreateContext( gl_api api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate ) { diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.h b/src/mesa/drivers/dri/tdfx/tdfx_context.h index 6e25cac301..29b0876f9f 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_context.h +++ b/src/mesa/drivers/dri/tdfx/tdfx_context.h @@ -937,7 +937,8 @@ struct tdfx_context { extern GLboolean -tdfxCreateContext( const __GLcontextModes *mesaVis, +tdfxCreateContext( gl_api api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate ); diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 9da96bdd45..4298c94855 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -456,7 +456,8 @@ FreeBuffer(struct via_context *vmesa) GLboolean -viaCreateContext(const __GLcontextModes *visual, +viaCreateContext(gl_api api, + const __GLcontextModes *visual, __DRIcontext *driContextPriv, void *sharedContextPrivate) { diff --git a/src/mesa/drivers/dri/unichrome/via_screen.h b/src/mesa/drivers/dri/unichrome/via_screen.h index aa662e01c0..51df0ce4eb 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.h +++ b/src/mesa/drivers/dri/unichrome/via_screen.h @@ -76,7 +76,8 @@ typedef struct { extern GLboolean -viaCreateContext(const __GLcontextModes *mesaVis, +viaCreateContext(gl_api api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate); -- cgit v1.2.3 From 4b69100bdcf26dbb5be4d600b7ca5f5cdf6e8f20 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 27 Apr 2010 11:04:51 -0400 Subject: dri: Add DRI entrypoints to create a context for a given API --- src/mesa/drivers/dri/i915/i830_context.c | 2 +- src/mesa/drivers/dri/i915/i915_context.c | 5 +++-- src/mesa/drivers/dri/i915/i915_context.h | 3 ++- src/mesa/drivers/dri/i965/brw_context.c | 5 +++-- src/mesa/drivers/dri/i965/brw_context.h | 3 ++- src/mesa/drivers/dri/intel/intel_context.c | 5 +++-- src/mesa/drivers/dri/intel/intel_context.h | 1 + src/mesa/drivers/dri/intel/intel_screen.c | 11 +++++++---- 8 files changed, 22 insertions(+), 13 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/dri/i915/i830_context.c b/src/mesa/drivers/dri/i915/i830_context.c index ebe8b15ca7..d52ea9812f 100644 --- a/src/mesa/drivers/dri/i915/i830_context.c +++ b/src/mesa/drivers/dri/i915/i830_context.c @@ -63,7 +63,7 @@ i830CreateContext(const __GLcontextModes * mesaVis, i830InitVtbl(i830); i830InitDriverFunctions(&functions); - if (!intelInitContext(intel, mesaVis, driContextPriv, + if (!intelInitContext(intel, __DRI_API_OPENGL, mesaVis, driContextPriv, sharedContextPrivate, &functions)) { FREE(i830); return GL_FALSE; diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index 4d86aae87d..b3fe1c05d6 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -94,7 +94,8 @@ i915InitDriverFunctions(struct dd_function_table *functions) extern const struct tnl_pipeline_stage *intel_pipeline[]; GLboolean -i915CreateContext(const __GLcontextModes * mesaVis, +i915CreateContext(int api, + const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate) { @@ -114,7 +115,7 @@ i915CreateContext(const __GLcontextModes * mesaVis, i915InitDriverFunctions(&functions); - if (!intelInitContext(intel, mesaVis, driContextPriv, + if (!intelInitContext(intel, api, mesaVis, driContextPriv, sharedContextPrivate, &functions)) { FREE(i915); return GL_FALSE; diff --git a/src/mesa/drivers/dri/i915/i915_context.h b/src/mesa/drivers/dri/i915/i915_context.h index b5169280f6..a7b9aae6f9 100644 --- a/src/mesa/drivers/dri/i915/i915_context.h +++ b/src/mesa/drivers/dri/i915/i915_context.h @@ -318,7 +318,8 @@ do { \ /*====================================================================== * i915_context.c */ -extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, +extern GLboolean i915CreateContext(int api, + const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate); diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 360fc12621..523a11aea3 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -68,7 +68,8 @@ static void brwInitDriverFunctions( struct dd_function_table *functions ) functions->Viewport = intel_viewport; } -GLboolean brwCreateContext( const __GLcontextModes *mesaVis, +GLboolean brwCreateContext( int api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate) { @@ -85,7 +86,7 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, brwInitVtbl( brw ); brwInitDriverFunctions( &functions ); - if (!intelInitContext( intel, mesaVis, driContextPriv, + if (!intelInitContext( intel, api, mesaVis, driContextPriv, sharedContextPrivate, &functions )) { printf("%s: failed to init intel context\n", __FUNCTION__); FREE(brw); diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 2855c93ea6..1f09651126 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -687,7 +687,8 @@ void brwInitVtbl( struct brw_context *brw ); /*====================================================================== * brw_context.c */ -GLboolean brwCreateContext( const __GLcontextModes *mesaVis, +GLboolean brwCreateContext( int api, + const __GLcontextModes *mesaVis, __DRIcontext *driContextPriv, void *sharedContextPrivate); diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 2ccc12010e..8922d574c1 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -586,6 +586,7 @@ intelInitDriverFunctions(struct dd_function_table *functions) GLboolean intelInitContext(struct intel_context *intel, + int api, const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate, @@ -601,8 +602,8 @@ intelInitContext(struct intel_context *intel, if (intelScreen->bufmgr == NULL) return GL_FALSE; - if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx, - functions, (void *) intel)) { + if (!_mesa_initialize_context_for_api(&intel->ctx, api, mesaVis, shareCtx, + functions, (void *) intel)) { printf("%s: failed to init mesa context\n", __FUNCTION__); return GL_FALSE; } diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 75dabc554c..02bb4d0d64 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -364,6 +364,7 @@ extern int INTEL_DEBUG; */ extern GLboolean intelInitContext(struct intel_context *intel, + int api, const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate, diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index b27e7a34a7..9b7ae73e45 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -356,10 +356,12 @@ extern GLboolean i830CreateContext(const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate); -extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, +extern GLboolean i915CreateContext(int api, + const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate); -extern GLboolean brwCreateContext(const __GLcontextModes * mesaVis, +extern GLboolean brwCreateContext(int api, + const __GLcontextModes * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate); @@ -375,7 +377,7 @@ intelCreateContext(gl_api api, #ifdef I915 if (IS_9XX(intelScreen->deviceID)) { if (!IS_965(intelScreen->deviceID)) { - return i915CreateContext(mesaVis, driContextPriv, + return i915CreateContext(api, mesaVis, driContextPriv, sharedContextPrivate); } } else { @@ -384,7 +386,8 @@ intelCreateContext(gl_api api, } #else if (IS_965(intelScreen->deviceID)) - return brwCreateContext(mesaVis, driContextPriv, sharedContextPrivate); + return brwCreateContext(api, mesaVis, + driContextPriv, sharedContextPrivate); #endif fprintf(stderr, "Unrecognized deviceID %x\n", intelScreen->deviceID); return GL_FALSE; -- cgit v1.2.3 From 5efee4d4e68067a3fd85b9ff6a2636f502538768 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 27 Apr 2010 21:43:40 -0400 Subject: intel: Advertise GLES1/2 for i915+ when enabled --- src/mesa/drivers/dri/intel/intel_screen.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 9b7ae73e45..2b54cda66d 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -434,6 +434,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp) struct intel_screen *intelScreen; GLenum fb_format[3]; GLenum fb_type[3]; + unsigned int api_mask; static const GLenum back_buffer_modes[] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML @@ -460,6 +461,17 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp) &intelScreen->deviceID)) return GL_FALSE; + api_mask = (1 << __DRI_API_OPENGL); +#if FEATURE_ES1 + api_mask |= (1 << __DRI_API_GLES); +#endif +#if FEATURE_ES2 + api_mask |= (1 << __DRI_API_GLES2); +#endif + + if (IS_9XX(intelScreen->deviceID) || IS_965(intelScreen->deviceID)) + psp->api_mask = api_mask; + if (!intel_init_bufmgr(intelScreen)) return GL_FALSE; -- cgit v1.2.3 From 0f68032a7cebe740421e5de4586d13c99a8728ab Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 27 Apr 2010 13:42:33 -0400 Subject: configure.ac: Add options to enable GLES1/2 API support --- configs/autoconf.in | 1 + configure.ac | 31 +++++++++++++++++++++++++++++++ src/mesa/Makefile | 1 + src/mesa/drivers/dri/Makefile.template | 1 + 4 files changed, 34 insertions(+) (limited to 'src/mesa/drivers') diff --git a/configs/autoconf.in b/configs/autoconf.in index b6cc9b3b73..c89441b251 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -14,6 +14,7 @@ ARCH_FLAGS = @ARCH_FLAGS@ ASM_FLAGS = @ASM_FLAGS@ PIC_FLAGS = @PIC_FLAGS@ DEFINES = @DEFINES@ +API_DEFINES = @API_DEFINES@ CFLAGS = @CPPFLAGS@ @CFLAGS@ \ $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES) CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ \ diff --git a/configure.ac b/configure.ac index 0e77707433..abb655135f 100644 --- a/configure.ac +++ b/configure.ac @@ -711,6 +711,37 @@ if test "x$with_dri_drivers" = x; then with_dri_drivers=no fi +dnl Determine which APIs to support +AC_ARG_ENABLE([opengl], + [AS_HELP_STRING([--disable-opengl], + [disable support for standard OpenGL API @<:@default=no@:>@])], + [enable_opengl="$enableval"], + [enable_opengl=yes]) +AC_ARG_ENABLE([gles1], + [AS_HELP_STRING([--enable-gles1], + [enable support for OpenGL ES 1.x API @<:@default=no@:>@])], + [enable_gles1="$enableval"], + [enable_gles1=no]) +AC_ARG_ENABLE([gles2], + [AS_HELP_STRING([--enable-gles2], + [enable support for OpenGL ES 2.x API @<:@default=no@:>@])], + [enable_gles2="$enableval"], + [enable_gles2=no]) + +API_DEFINES="" +if test "x$enable_opengl" = xno; then + API_DEFINES="$API_DEFINES -DFEATURE_GL=0" +else + API_DEFINES="$API_DEFINES -DFEATURE_GL=1" +fi +if test "x$enable_gles1" = xyes; then + API_DEFINES="$API_DEFINES -DFEATURE_ES1=1" +fi +if test "x$enable_gles2" = xyes; then + API_DEFINES="$API_DEFINES -DFEATURE_ES2=1" +fi +AC_SUBST([API_DEFINES]) + dnl If $with_dri_drivers is yes, directories will be added through dnl platform checks DRI_DIRS="" diff --git a/src/mesa/Makefile b/src/mesa/Makefile index e4040881f1..44e091f240 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -16,6 +16,7 @@ include sources.mak .S.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ +CFLAGS += $(API_DEFINES) # Default: build dependencies, then asm_subdirs, GLSL built-in lib, diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 4cdd51efee..4b9a0c1786 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -31,6 +31,7 @@ SHARED_INCLUDES = \ -I$(TOP)/src/egl/drivers/dri \ $(LIBDRM_CFLAGS) +CFLAGS += $(API_DEFINES) ##### RULES ##### -- cgit v1.2.3 From a5107b0a5cb1ac9f112aa498f57c13580bd56cb3 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 27 Apr 2010 14:57:51 -0400 Subject: intel: Only register ES2 extensions for ES2 contexts --- src/mesa/drivers/dri/i915/Makefile | 1 + src/mesa/drivers/dri/i915/intel_extensions_es2.c | 1 + src/mesa/drivers/dri/i965/Makefile | 1 + src/mesa/drivers/dri/i965/intel_extensions_es2.c | 1 + src/mesa/drivers/dri/intel/intel_context.c | 11 ++- src/mesa/drivers/dri/intel/intel_extensions.h | 2 +- src/mesa/drivers/dri/intel/intel_extensions_es2.c | 93 +++++++++++++++++++++++ 7 files changed, 108 insertions(+), 2 deletions(-) create mode 120000 src/mesa/drivers/dri/i915/intel_extensions_es2.c create mode 120000 src/mesa/drivers/dri/i965/intel_extensions_es2.c create mode 100644 src/mesa/drivers/dri/intel/intel_extensions_es2.c (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index 5b49d0c77c..71ee753748 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -16,6 +16,7 @@ DRIVER_SOURCES = \ intel_batchbuffer.c \ intel_clear.c \ intel_extensions.c \ + intel_extensions_es2.c \ intel_mipmap_tree.c \ intel_tex_layout.c \ intel_tex_image.c \ diff --git a/src/mesa/drivers/dri/i915/intel_extensions_es2.c b/src/mesa/drivers/dri/i915/intel_extensions_es2.c new file mode 120000 index 0000000000..0ec1ceee78 --- /dev/null +++ b/src/mesa/drivers/dri/i915/intel_extensions_es2.c @@ -0,0 +1 @@ +../intel/intel_extensions_es2.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index 842d4b7aa1..a0039e800d 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -13,6 +13,7 @@ DRIVER_SOURCES = \ intel_context.c \ intel_decode.c \ intel_extensions.c \ + intel_extensions_es2.c \ intel_fbo.c \ intel_mipmap_tree.c \ intel_regions.c \ diff --git a/src/mesa/drivers/dri/i965/intel_extensions_es2.c b/src/mesa/drivers/dri/i965/intel_extensions_es2.c new file mode 120000 index 0000000000..0ec1ceee78 --- /dev/null +++ b/src/mesa/drivers/dri/i965/intel_extensions_es2.c @@ -0,0 +1 @@ +../intel/intel_extensions_es2.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 8922d574c1..8ee9a292a1 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -737,7 +737,16 @@ intelInitContext(struct intel_context *intel, intel->RenderIndex = ~0; - intelInitExtensions(ctx); + switch (ctx->API) { + case API_OPENGL: + intelInitExtensions(ctx); + break; + case API_OPENGLES: + break; + case API_OPENGLES2: + intelInitExtensionsES2(ctx); + break; + } INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control); if (INTEL_DEBUG & DEBUG_BUFMGR) diff --git a/src/mesa/drivers/dri/intel/intel_extensions.h b/src/mesa/drivers/dri/intel/intel_extensions.h index e78e07356e..236442a4d6 100644 --- a/src/mesa/drivers/dri/intel/intel_extensions.h +++ b/src/mesa/drivers/dri/intel/intel_extensions.h @@ -33,7 +33,7 @@ extern void intelInitExtensions(GLcontext *ctx); extern void -intelFlushDrawable(__DRIdrawable *drawable); +intelInitExtensionsES2(GLcontext *ctx); #endif diff --git a/src/mesa/drivers/dri/intel/intel_extensions_es2.c b/src/mesa/drivers/dri/intel/intel_extensions_es2.c new file mode 100644 index 0000000000..8a6c15f6d2 --- /dev/null +++ b/src/mesa/drivers/dri/intel/intel_extensions_es2.c @@ -0,0 +1,93 @@ +/************************************************************************** + * + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +#include "main/extensions.h" + +#include "intel_extensions.h" +#include "utils.h" + +static const char *es2_extensions[] = { + /* Used by mesa internally (cf all_mesa_extensions in ../common/utils.c) */ + "GL_ARB_draw_buffers", + "GL_ARB_multisample", + "GL_ARB_texture_compression", + "GL_ARB_transpose_matrix", + "GL_ARB_vertex_buffer_object", + "GL_ARB_window_pos", + "GL_EXT_blend_func_separate", + "GL_EXT_compiled_vertex_array", + "GL_EXT_multi_draw_arrays", + "GL_EXT_polygon_offset", + "GL_EXT_texture_object", + "GL_EXT_vertex_array", + "GL_IBM_multimode_draw_arrays", + "GL_MESA_window_pos", + "GL_NV_vertex_program", + + /* Required by GLES2 */ + "GL_ARB_fragment_program", + "GL_ARB_fragment_shader", + "GL_ARB_multitexture", + "GL_ARB_shader_objects", + "GL_ARB_texture_cube_map", + "GL_ARB_texture_mirrored_repeat", + "GL_ARB_texture_non_power_of_two", + "GL_ARB_vertex_shader", + "GL_EXT_blend_color", + "GL_EXT_blend_equation_separate", + "GL_EXT_blend_minmax", + "GL_EXT_blend_subtract", + "GL_EXT_stencil_wrap", + + /* Optional GLES2 */ + "GL_ARB_framebuffer_object", + "GL_EXT_texture_filter_anisotropic", + "GL_ARB_depth_texture", + "GL_EXT_packed_depth_stencil", + +#if FEATURE_OES_EGL_image + "GL_OES_EGL_image", +#endif + + NULL, +}; + +/** + * Initializes potential list of extensions if ctx == NULL, or actually enables + * extensions for a context. + */ +void +intelInitExtensionsES2(GLcontext *ctx) +{ + int i; + + /* Can't use driInitExtensions() since it uses extensions from + * main/remap_helper.h when called the first time. */ + + for (i = 0; es2_extensions[i]; i++) + _mesa_enable_extension(ctx, es2_extensions[i]); +} -- cgit v1.2.3