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;
goto fail;
cPriv->driverPrivate = ctx;
- ctx->api = api;
ctx->cPriv = cPriv;
ctx->sPriv = sPriv;
ctx->lock = screen->drmLock;
if (ctx->st == NULL)
goto fail;
ctx->st->st_manager_private = (void *) ctx;
+ ctx->stapi = stapi;
dri_init_extensions(ctx);
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);
}
}
__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);
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;
}
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);
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))
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);