mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 20:08:06 +02:00
mesa: Track the OpenGL API we're implementing in the context
This introduces a new way to create or initialize a context: _mesa_create_context_for_api and _mesa_initialize_context_for_api which in addition to the current arguments take an api enum to indicate which OpenGL API the context should implement. At this point the API field in GLcontext isn't used anywhere, but later commits will key certain functionality off of it. The _mesa_create_context and _mesa_initialize_context functions are kept in place as wrappers around the *_for_api versions, passing in API_OPENGL to get the same behavior as before.
This commit is contained in:
parent
d9793fc3ac
commit
07f9b7cf82
3 changed files with 65 additions and 11 deletions
|
|
@ -781,6 +781,7 @@ alloc_dispatch_table(void)
|
|||
* for debug flags.
|
||||
*
|
||||
* \param ctx the context to initialize
|
||||
* \param api the GL API type to create the context for
|
||||
* \param visual describes the visual attributes for this context
|
||||
* \param share_list points to context to share textures, display lists,
|
||||
* etc with, or NULL
|
||||
|
|
@ -789,11 +790,12 @@ alloc_dispatch_table(void)
|
|||
* \param driverContext pointer to driver-specific context data
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_initialize_context(GLcontext *ctx,
|
||||
const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext)
|
||||
_mesa_initialize_context_for_api(GLcontext *ctx,
|
||||
gl_api api,
|
||||
const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext)
|
||||
{
|
||||
struct gl_shared_state *shared;
|
||||
|
||||
|
|
@ -804,6 +806,7 @@ _mesa_initialize_context(GLcontext *ctx,
|
|||
/* misc one-time initializations */
|
||||
one_time_init(ctx);
|
||||
|
||||
ctx->API = api;
|
||||
ctx->Visual = *visual;
|
||||
ctx->DrawBuffer = NULL;
|
||||
ctx->ReadBuffer = NULL;
|
||||
|
|
@ -882,6 +885,20 @@ _mesa_initialize_context(GLcontext *ctx,
|
|||
return GL_TRUE;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
_mesa_initialize_context(GLcontext *ctx,
|
||||
const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext)
|
||||
{
|
||||
return _mesa_initialize_context_for_api(ctx,
|
||||
API_OPENGL,
|
||||
visual,
|
||||
share_list,
|
||||
driverFunctions,
|
||||
driverContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and initialize a GLcontext structure.
|
||||
|
|
@ -889,6 +906,7 @@ _mesa_initialize_context(GLcontext *ctx,
|
|||
* we need to at least call driverFunctions->NewTextureObject to initialize
|
||||
* the rendering context.
|
||||
*
|
||||
* \param api the GL API type to create the context for
|
||||
* \param visual a GLvisual pointer (we copy the struct contents)
|
||||
* \param share_list another context to share display lists with or NULL
|
||||
* \param driverFunctions points to the dd_function_table into which the
|
||||
|
|
@ -898,10 +916,11 @@ _mesa_initialize_context(GLcontext *ctx,
|
|||
* \return pointer to a new __GLcontextRec or NULL if error.
|
||||
*/
|
||||
GLcontext *
|
||||
_mesa_create_context(const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext)
|
||||
_mesa_create_context_for_api(gl_api api,
|
||||
const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext)
|
||||
{
|
||||
GLcontext *ctx;
|
||||
|
||||
|
|
@ -912,8 +931,8 @@ _mesa_create_context(const GLvisual *visual,
|
|||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
if (_mesa_initialize_context(ctx, visual, share_list,
|
||||
driverFunctions, driverContext)) {
|
||||
if (_mesa_initialize_context_for_api(ctx, api, visual, share_list,
|
||||
driverFunctions, driverContext)) {
|
||||
return ctx;
|
||||
}
|
||||
else {
|
||||
|
|
@ -922,6 +941,17 @@ _mesa_create_context(const GLvisual *visual,
|
|||
}
|
||||
}
|
||||
|
||||
GLcontext *
|
||||
_mesa_create_context(const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext)
|
||||
{
|
||||
return _mesa_create_context_for_api(API_OPENGL, visual,
|
||||
share_list,
|
||||
driverFunctions,
|
||||
driverContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the data associated with the given context.
|
||||
|
|
|
|||
|
|
@ -112,6 +112,21 @@ _mesa_initialize_context( GLcontext *ctx,
|
|||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext );
|
||||
|
||||
extern GLcontext *
|
||||
_mesa_create_context_for_api(gl_api api,
|
||||
const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_initialize_context_for_api(GLcontext *ctx,
|
||||
gl_api api,
|
||||
const GLvisual *visual,
|
||||
GLcontext *share_list,
|
||||
const struct dd_function_table *driverFunctions,
|
||||
void *driverContext);
|
||||
|
||||
extern void
|
||||
_mesa_initialize_context_extra(GLcontext *ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -2815,6 +2815,14 @@ struct gl_dlist_state
|
|||
} Current;
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum for the OpenGL APIs we know about and may support.
|
||||
*/
|
||||
typedef enum {
|
||||
API_OPENGL,
|
||||
API_OPENGLES,
|
||||
API_OPENGLES2,
|
||||
} gl_api;
|
||||
|
||||
/**
|
||||
* Mesa rendering context.
|
||||
|
|
@ -2833,6 +2841,7 @@ struct __GLcontextRec
|
|||
|
||||
/** \name API function pointer tables */
|
||||
/*@{*/
|
||||
gl_api API;
|
||||
struct _glapi_table *Save; /**< Display list save functions */
|
||||
struct _glapi_table *Exec; /**< Execute functions */
|
||||
struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue