swrast: add an interface createNewContextForAPI
This new interface could set up context for OpenGL, OpenGL ES1 and OpenGL ES2. It will be used by egl_dri2 driver. Signed-off-by: Haitao Feng <haitao.feng@intel.com>
This commit is contained in:

committed by
Kristian Høgsberg

parent
610c24b19d
commit
b43a147128
@@ -657,7 +657,7 @@ struct __DRIlegacyExtensionRec {
|
|||||||
* conjunction with the core extension.
|
* conjunction with the core extension.
|
||||||
*/
|
*/
|
||||||
#define __DRI_SWRAST "DRI_SWRast"
|
#define __DRI_SWRAST "DRI_SWRast"
|
||||||
#define __DRI_SWRAST_VERSION 1
|
#define __DRI_SWRAST_VERSION 2
|
||||||
|
|
||||||
struct __DRIswrastExtensionRec {
|
struct __DRIswrastExtensionRec {
|
||||||
__DRIextension base;
|
__DRIextension base;
|
||||||
@@ -670,6 +670,13 @@ struct __DRIswrastExtensionRec {
|
|||||||
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
|
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
|
||||||
const __DRIconfig *config,
|
const __DRIconfig *config,
|
||||||
void *loaderPrivate);
|
void *loaderPrivate);
|
||||||
|
|
||||||
|
/* Since version 2 */
|
||||||
|
__DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
|
||||||
|
int api,
|
||||||
|
const __DRIconfig *config,
|
||||||
|
__DRIcontext *shared,
|
||||||
|
void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -121,6 +121,48 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
|
|||||||
return pcp;
|
return pcp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __DRIcontext *
|
||||||
|
driCreateNewContextForAPI(__DRIscreen *psp, int api,
|
||||||
|
const __DRIconfig *config,
|
||||||
|
__DRIcontext *shared, void *data)
|
||||||
|
{
|
||||||
|
__DRIcontext *pcp;
|
||||||
|
void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
|
||||||
|
gl_api mesa_api;
|
||||||
|
|
||||||
|
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;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcp = CALLOC_STRUCT(__DRIcontextRec);
|
||||||
|
if (!pcp)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pcp->loaderPrivate = data;
|
||||||
|
|
||||||
|
pcp->driScreenPriv = psp;
|
||||||
|
pcp->driDrawablePriv = NULL;
|
||||||
|
pcp->driReadablePriv = NULL;
|
||||||
|
|
||||||
|
if (!driDriverAPI.CreateContext(mesa_api,
|
||||||
|
&config->modes, pcp, shareCtx)) {
|
||||||
|
FREE(pcp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pcp;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
driDestroyContext(__DRIcontext *pcp)
|
driDestroyContext(__DRIcontext *pcp)
|
||||||
{
|
{
|
||||||
@@ -269,5 +311,6 @@ const __DRIcoreExtension driCoreExtension = {
|
|||||||
const __DRIswrastExtension driSWRastExtension = {
|
const __DRIswrastExtension driSWRastExtension = {
|
||||||
{ __DRI_SWRAST, __DRI_SWRAST_VERSION },
|
{ __DRI_SWRAST, __DRI_SWRAST_VERSION },
|
||||||
driCreateNewScreen,
|
driCreateNewScreen,
|
||||||
driCreateNewDrawable
|
driCreateNewDrawable,
|
||||||
|
driCreateNewContextForAPI
|
||||||
};
|
};
|
||||||
|
@@ -561,6 +561,60 @@ swrast_init_driver_functions(struct dd_function_table *driver)
|
|||||||
driver->ChooseTextureFormat = swrastChooseTextureFormat;
|
driver->ChooseTextureFormat = swrastChooseTextureFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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_framebuffer_blit",
|
||||||
|
"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",
|
||||||
|
"GL_EXT_framebuffer_object",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
InitExtensionsES2(struct gl_context *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]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context-related functions.
|
* Context-related functions.
|
||||||
@@ -597,7 +651,7 @@ dri_create_context(gl_api api,
|
|||||||
mesaCtx = &ctx->Base;
|
mesaCtx = &ctx->Base;
|
||||||
|
|
||||||
/* basic context setup */
|
/* basic context setup */
|
||||||
if (!_mesa_initialize_context(mesaCtx, visual, sharedCtx, &functions, (void *) cPriv)) {
|
if (!_mesa_initialize_context_for_api(mesaCtx, api, visual, sharedCtx, &functions, (void *) cPriv)) {
|
||||||
goto context_fail;
|
goto context_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,16 +671,29 @@ dri_create_context(gl_api api,
|
|||||||
tnl->Driver.RunPipeline = _tnl_run_pipeline;
|
tnl->Driver.RunPipeline = _tnl_run_pipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
_mesa_enable_sw_extensions(mesaCtx);
|
|
||||||
_mesa_enable_1_3_extensions(mesaCtx);
|
|
||||||
_mesa_enable_1_4_extensions(mesaCtx);
|
|
||||||
_mesa_enable_1_5_extensions(mesaCtx);
|
|
||||||
_mesa_enable_2_0_extensions(mesaCtx);
|
|
||||||
_mesa_enable_2_1_extensions(mesaCtx);
|
|
||||||
|
|
||||||
_mesa_meta_init(mesaCtx);
|
_mesa_meta_init(mesaCtx);
|
||||||
|
_mesa_enable_sw_extensions(mesaCtx);
|
||||||
|
|
||||||
driInitExtensions( mesaCtx, NULL, GL_FALSE );
|
switch (api) {
|
||||||
|
case API_OPENGL:
|
||||||
|
_mesa_enable_1_3_extensions(mesaCtx);
|
||||||
|
_mesa_enable_1_4_extensions(mesaCtx);
|
||||||
|
_mesa_enable_1_5_extensions(mesaCtx);
|
||||||
|
_mesa_enable_2_0_extensions(mesaCtx);
|
||||||
|
_mesa_enable_2_1_extensions(mesaCtx);
|
||||||
|
|
||||||
|
driInitExtensions( mesaCtx, NULL, GL_FALSE );
|
||||||
|
break;
|
||||||
|
case API_OPENGLES:
|
||||||
|
_mesa_enable_1_3_extensions(mesaCtx);
|
||||||
|
_mesa_enable_1_4_extensions(mesaCtx);
|
||||||
|
_mesa_enable_1_5_extensions(mesaCtx);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case API_OPENGLES2:
|
||||||
|
InitExtensionsES2( mesaCtx);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user