{
__DRIscreen *sPriv = cPriv->driScreenPriv;
struct dri_screen *screen = dri_screen(sPriv);
- struct st_api *stapi = screen->st_api;
+ struct st_api *stapi;
struct dri_context *ctx = NULL;
struct st_context_iface *st_share = NULL;
struct st_visual stvis;
- if (api != API_OPENGL)
+ assert(api <= API_OPENGLES2);
+ stapi = screen->st_api[api];
+ if (!stapi)
return GL_FALSE;
if (sharedContextPrivate) {
goto fail;
cPriv->driverPrivate = ctx;
+ ctx->api = api;
ctx->cPriv = cPriv;
ctx->sPriv = sPriv;
ctx->lock = screen->drmLock;
/* 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;
+ struct st_api *stapi = screen->st_api[ctx->api];
if (--ctx->bind_count == 0) {
if (ctx->st == stapi->get_current(stapi)) {
/* 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;
+ 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);
dri_get_current(__DRIscreen *sPriv)
{
struct dri_screen *screen = dri_screen(sPriv);
- struct st_api *stapi = screen->st_api;
- struct st_context_iface *st;
-
- st = stapi->get_current(stapi);
+ struct st_api *stapi;
+ struct st_context_iface *st = NULL;
+ gl_api api;
+
+ /* XXX: How do we do this when the screen supports
+ multiple rendering API's? Pick the first one,
+ like this? (NB: all three API's use the same
+ implementation of get_current (see st_manager.c),
+ so maybe it doesn't matter right now since
+ they'll all return the same result.) */
+ for (api = API_OPENGL; api <= API_OPENGLES2; ++api) {
+ stapi = screen->st_api[api];
+ if (!stapi)
+ continue;
+ st = stapi->get_current(stapi);
+ if (st)
+ break;
+ }
return (struct dri_context *) (st) ? st->st_manager_private : NULL;
}
void
dri_destroy_screen_helper(struct dri_screen * screen)
{
- if (screen->st_api && screen->st_api->destroy)
- screen->st_api->destroy(screen->st_api);
+ 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]);
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 = st_gl_api_create();
- if (!screen->st_api)
+ 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();
+
+ if (!screen->st_api[API_OPENGL] &&
+ !screen->st_api[API_OPENGLES1] &&
+ !screen->st_api[API_OPENGLES2])
return NULL;
if(pscreen->get_param(pscreen, PIPE_CAP_NPOT_TEXTURES))