st/dri: Use enum st_api_type internally.

This commit is contained in:
Chia-I Wu 2010-09-08 17:41:43 +08:00
parent 8e3b658b7f
commit 444d8408e7
5 changed files with 39 additions and 27 deletions

View file

@ -59,8 +59,20 @@ dri_create_context(gl_api api, const __GLcontextModes * visual,
struct st_context_iface *st_share = NULL;
struct st_visual stvis;
assert(api <= API_OPENGLES2);
stapi = screen->st_api[api];
switch (api) {
case API_OPENGL:
stapi = screen->st_api[ST_API_OPENGL];
break;
case API_OPENGLES:
stapi = screen->st_api[ST_API_OPENGL_ES1];
break;
case API_OPENGLES2:
stapi = screen->st_api[ST_API_OPENGL_ES2];
break;
default:
stapi = NULL;
break;
}
if (!stapi)
return GL_FALSE;
@ -73,7 +85,6 @@ dri_create_context(gl_api api, const __GLcontextModes * visual,
goto fail;
cPriv->driverPrivate = ctx;
ctx->api = api;
ctx->cPriv = cPriv;
ctx->sPriv = sPriv;
ctx->lock = screen->drmLock;
@ -86,6 +97,7 @@ dri_create_context(gl_api api, const __GLcontextModes * visual,
if (ctx->st == NULL)
goto fail;
ctx->st->st_manager_private = (void *) ctx;
ctx->stapi = stapi;
dri_init_extensions(ctx);
@ -125,14 +137,12 @@ GLboolean
dri_unbind_context(__DRIcontext * cPriv)
{
/* dri_util.c ensures cPriv is not null */
struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
struct dri_context *ctx = dri_context(cPriv);
struct st_api *stapi = screen->st_api[ctx->api];
if (--ctx->bind_count == 0) {
if (ctx->st == stapi->get_current(stapi)) {
if (ctx->st == ctx->stapi->get_current(ctx->stapi)) {
ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
stapi->make_current(stapi, NULL, NULL, NULL);
ctx->stapi->make_current(ctx->stapi, NULL, NULL, NULL);
}
}
@ -145,12 +155,10 @@ dri_make_current(__DRIcontext * cPriv,
__DRIdrawable * driReadPriv)
{
/* dri_util.c ensures cPriv is not null */
struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
struct dri_context *ctx = dri_context(cPriv);
struct st_api *stapi = screen->st_api[ctx->api];
struct dri_drawable *draw = dri_drawable(driDrawPriv);
struct dri_drawable *read = dri_drawable(driReadPriv);
struct st_context_iface *old_st = stapi->get_current(stapi);
struct st_context_iface *old_st = ctx->stapi->get_current(ctx->stapi);
if (old_st && old_st != ctx->st)
old_st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
@ -166,7 +174,7 @@ dri_make_current(__DRIcontext * cPriv,
read->texture_stamp = driReadPriv->lastStamp - 1;
}
stapi->make_current(stapi, ctx->st, &draw->base, &read->base);
ctx->stapi->make_current(ctx->stapi, ctx->st, &draw->base, &read->base);
return GL_TRUE;
}

View file

@ -37,7 +37,8 @@
struct pipe_context;
struct pipe_fence;
struct st_context;
struct st_api;
struct st_context_iface;
struct dri_drawable;
struct dri_context
@ -58,7 +59,7 @@ struct dri_context
unsigned int bind_count;
/* gallium */
gl_api api;
struct st_api *stapi;
struct st_context_iface *st;
/* hooks filled in by dri2 & drisw */

View file

@ -344,10 +344,12 @@ dri_destroy_option_cache(struct dri_screen * screen)
void
dri_destroy_screen_helper(struct dri_screen * screen)
{
gl_api api;
for (api = API_OPENGL; api <= API_OPENGLES2; ++api)
if (screen->st_api[api] && screen->st_api[api]->destroy)
screen->st_api[api]->destroy(screen->st_api[api]);
int i;
for (i = 0; i < ST_API_COUNT; i++) {
if (screen->st_api[i] && screen->st_api[i]->destroy)
screen->st_api[i]->destroy(screen->st_api[i]);
}
if (screen->base.screen)
screen->base.screen->destroy(screen->base.screen);
@ -381,13 +383,14 @@ dri_init_screen_helper(struct dri_screen *screen,
screen->base.get_egl_image = dri_get_egl_image;
screen->base.get_param = dri_get_param;
screen->st_api[API_OPENGL] = st_gl_api_create();
screen->st_api[API_OPENGLES1] = st_gl_api_create_es1();
screen->st_api[API_OPENGLES2] = st_gl_api_create_es2();
screen->st_api[ST_API_OPENGL] = st_gl_api_create();
screen->st_api[ST_API_OPENGL_ES1] = st_gl_api_create_es1();
screen->st_api[ST_API_OPENGL_ES2] = st_gl_api_create_es2();
/* no ST_API_OPENVG */
if (!screen->st_api[API_OPENGL] &&
!screen->st_api[API_OPENGLES1] &&
!screen->st_api[API_OPENGLES2])
if (!screen->st_api[ST_API_OPENGL] &&
!screen->st_api[ST_API_OPENGL_ES1] &&
!screen->st_api[ST_API_OPENGL_ES2])
return NULL;
if(pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES))

View file

@ -47,7 +47,7 @@ struct dri_screen
{
/* st_api */
struct st_manager base;
struct st_api *st_api[1+API_OPENGLES2]; /* GL, GLES1, GLES2 */
struct st_api *st_api[ST_API_COUNT];
/* on old libGL's invalidate doesn't get called as it should */
boolean broken_invalidate;

View file

@ -440,11 +440,11 @@ dri2_init_screen(__DRIscreen * sPriv)
goto fail;
sPriv->api_mask = 0;
if (screen->st_api[API_OPENGL])
if (screen->st_api[ST_API_OPENGL])
sPriv->api_mask |= 1 << __DRI_API_OPENGL;
if (screen->st_api[API_OPENGLES1])
if (screen->st_api[ST_API_OPENGL_ES1])
sPriv->api_mask |= 1 << __DRI_API_GLES;
if (screen->st_api[API_OPENGLES2])
if (screen->st_api[ST_API_OPENGL_ES2])
sPriv->api_mask |= 1 << __DRI_API_GLES2;
screen->auto_fake_front = dri_with_format(sPriv);