summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/dri/common
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-09-08 17:41:43 +0800
committerChia-I Wu <[email protected]>2010-09-08 18:20:44 +0800
commit444d8408e75bb2bce019769da59802f05c3d5fab (patch)
tree9913fda53f6727f2d09da92e5f0aaa0b11f9cc34 /src/gallium/state_trackers/dri/common
parent8e3b658b7fdc1c2a2b9b6bd942a811adbf1ac4ab (diff)
st/dri: Use enum st_api_type internally.
Diffstat (limited to 'src/gallium/state_trackers/dri/common')
-rw-r--r--src/gallium/state_trackers/dri/common/dri_context.c30
-rw-r--r--src/gallium/state_trackers/dri/common/dri_context.h5
-rw-r--r--src/gallium/state_trackers/dri/common/dri_screen.c23
-rw-r--r--src/gallium/state_trackers/dri/common/dri_screen.h2
4 files changed, 36 insertions, 24 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
index 6a8e3b01402..0703a2b88d9 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -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;
}
diff --git a/src/gallium/state_trackers/dri/common/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h
index 7b92e7a0e7a..ffe9eba13c8 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.h
+++ b/src/gallium/state_trackers/dri/common/dri_context.h
@@ -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 */
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c
index 853ee1e5fab..9d13d0d52e1 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.c
+++ b/src/gallium/state_trackers/dri/common/dri_screen.c
@@ -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))
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h
index 41414611c38..baa204cd10f 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.h
+++ b/src/gallium/state_trackers/dri/common/dri_screen.h
@@ -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;