aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/dri/common/dri_context.c
diff options
context:
space:
mode:
authornobled <[email protected]>2010-08-30 20:23:54 +0000
committerChia-I Wu <[email protected]>2010-09-08 17:25:01 +0800
commit8e3b658b7fdc1c2a2b9b6bd942a811adbf1ac4ab (patch)
treea7863aa7d00182bda0ca9bdf834df3a2ad6bd2ad /src/gallium/state_trackers/dri/common/dri_context.c
parentecd7ec9d62d2ba919410218f4cf3f69772681f3c (diff)
st/dri: Add multi-api support
Make st/dri screens capable of creating OpenGL ES and OpenGL ES2 contexts. TODO: Figure out the "get_current" problem with multiple st_api's for real. (s/API_OPENGLES1/API_OPENGLES/ by Chia-I Wu)
Diffstat (limited to 'src/gallium/state_trackers/dri/common/dri_context.c')
-rw-r--r--src/gallium/state_trackers/dri/common/dri_context.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
index 931cffafcea..6a8e3b01402 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -54,12 +54,14 @@ dri_create_context(gl_api api, const __GLcontextModes * visual,
{
__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) {
@@ -71,6 +73,7 @@ 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;
@@ -124,7 +127,7 @@ 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;
+ struct st_api *stapi = screen->st_api[ctx->api];
if (--ctx->bind_count == 0) {
if (ctx->st == stapi->get_current(stapi)) {
@@ -144,7 +147,7 @@ dri_make_current(__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;
+ 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);
@@ -172,10 +175,24 @@ struct dri_context *
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;
}