summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/dri/common
diff options
context:
space:
mode:
authorJakob Bornecrantz <wallbraker@gmail.com>2010-04-24 11:08:58 +0100
committerJakob Bornecrantz <wallbraker@gmail.com>2010-04-26 00:40:17 +0100
commita66b391edf746a5eb0cb4aad1ff2e546df00a11d (patch)
tree7aca97c5795a5ddf946c4397ff15ff00e5a66631 /src/gallium/state_trackers/dri/common
parentea6a52a1f8e7fd72b5506218c31e58088131f1f5 (diff)
st/dri: Make st_manager the base for dri_screen
Diffstat (limited to 'src/gallium/state_trackers/dri/common')
-rw-r--r--src/gallium/state_trackers/dri/common/dri_context.c15
-rw-r--r--src/gallium/state_trackers/dri/common/dri_context.h2
-rw-r--r--src/gallium/state_trackers/dri/common/dri_screen.c6
-rw-r--r--src/gallium/state_trackers/dri/common/dri_screen.h6
-rw-r--r--src/gallium/state_trackers/dri/common/dri_st_api.c70
-rw-r--r--src/gallium/state_trackers/dri/common/dri_st_api.h9
6 files changed, 29 insertions, 79 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
index f14f4130bf..97e3b0628f 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -53,9 +53,9 @@ GLboolean
dri_create_context(const __GLcontextModes * visual,
__DRIcontext * cPriv, void *sharedContextPrivate)
{
- struct st_api *stapi = dri_get_st_api();
__DRIscreen *sPriv = cPriv->driScreenPriv;
struct dri_screen *screen = dri_screen(sPriv);
+ struct st_api *stapi = screen->st_api;
struct dri_context *ctx = NULL;
struct st_context_iface *st_share = NULL;
struct st_visual stvis;
@@ -77,7 +77,7 @@ dri_create_context(const __GLcontextModes * visual,
&screen->optionCache, sPriv->myNum, "dri");
dri_fill_st_visual(&stvis, screen, visual);
- ctx->st = stapi->create_context(stapi, screen->smapi, &stvis, st_share);
+ ctx->st = stapi->create_context(stapi, &screen->base, &stvis, st_share);
if (ctx->st == NULL)
goto fail;
ctx->st->st_manager_private = (void *) ctx;
@@ -119,7 +119,8 @@ dri_destroy_context(__DRIcontext * cPriv)
GLboolean
dri_unbind_context(__DRIcontext * cPriv)
{
- struct st_api *stapi = dri_get_st_api();
+ struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+ struct st_api *stapi = screen->st_api;
if (cPriv) {
struct dri_context *ctx = dri_context(cPriv);
@@ -140,7 +141,8 @@ dri_make_current(__DRIcontext * cPriv,
__DRIdrawable * driDrawPriv,
__DRIdrawable * driReadPriv)
{
- struct st_api *stapi = dri_get_st_api();
+ struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+ struct st_api *stapi = screen->st_api;
if (cPriv) {
struct dri_context *ctx = dri_context(cPriv);
@@ -173,9 +175,10 @@ dri_make_current(__DRIcontext * cPriv,
}
struct dri_context *
-dri_get_current(void)
+dri_get_current(__DRIscreen *sPriv)
{
- struct st_api *stapi = dri_get_st_api();
+ struct dri_screen *screen = dri_screen(sPriv);
+ struct st_api *stapi = screen->st_api;
struct st_context_iface *st;
st = stapi->get_current(stapi);
diff --git a/src/gallium/state_trackers/dri/common/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h
index 594618874a..9fe6b58101 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.h
+++ b/src/gallium/state_trackers/dri/common/dri_context.h
@@ -80,7 +80,7 @@ dri_make_current(__DRIcontext * driContextPriv,
__DRIdrawable * driReadPriv);
struct dri_context *
-dri_get_current(void);
+dri_get_current(__DRIscreen * driScreenPriv);
boolean
dri_create_context(const __GLcontextModes * visual,
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c
index 4bfbc6e80b..7060107e73 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.c
+++ b/src/gallium/state_trackers/dri/common/dri_screen.c
@@ -304,9 +304,6 @@ dri_destroy_screen_helper(struct dri_screen * screen)
{
dri1_destroy_pipe_context(screen);
- if (screen->smapi)
- dri_destroy_st_manager(screen->smapi);
-
if (screen->pipe_screen)
screen->pipe_screen->destroy(screen->pipe_screen);
@@ -336,8 +333,7 @@ dri_init_screen_helper(struct dri_screen *screen,
return NULL;
}
- screen->smapi = dri_create_st_manager(screen);
- if (!screen->smapi)
+ if (!dri_init_st_manager(screen))
return NULL;
driParseOptionInfo(&screen->optionCache,
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h
index 6e814af615..98cb9e7550 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.h
+++ b/src/gallium/state_trackers/dri/common/dri_screen.h
@@ -46,6 +46,10 @@ struct dri_drawable;
struct dri_screen
{
+ /* st_api */
+ struct st_manager base;
+ struct st_api *st_api;
+
/* dri */
__DRIscreen *sPriv;
@@ -75,8 +79,6 @@ struct dri_screen
boolean sd_depth_bits_last;
boolean auto_fake_front;
- struct st_manager *smapi;
-
/* used only by DRI1 */
struct pipe_context *dri1_pipe;
};
diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c
index 9702acea5c..6c8a7e82ab 100644
--- a/src/gallium/state_trackers/dri/common/dri_st_api.c
+++ b/src/gallium/state_trackers/dri/common/dri_st_api.c
@@ -170,39 +170,6 @@ dri_st_framebuffer_validate_att(struct st_framebuffer_iface *stfbi,
stfbi->validate(stfbi, statts, count, NULL);
}
-/**
- * Reference counted st_api.
- */
-static struct {
- int32_t refcnt;
- struct st_api *stapi;
-} dri_st_api;
-
-/**
- * Add a reference to the st_api of the state tracker.
- */
-static void
-_dri_get_st_api(void)
-{
- p_atomic_inc(&dri_st_api.refcnt);
- if (p_atomic_read(&dri_st_api.refcnt) == 1)
- dri_st_api.stapi = st_gl_api_create();
-}
-
-/**
- * Remove a reference to the st_api of the state tracker.
- */
-static void
-_dri_put_st_api(void)
-{
- struct st_api *stapi = dri_st_api.stapi;
-
- if (p_atomic_dec_zero(&dri_st_api.refcnt)) {
- stapi->destroy(dri_st_api.stapi);
- dri_st_api.stapi = NULL;
- }
-}
-
static boolean
dri_st_manager_get_egl_image(struct st_manager *smapi,
struct st_egl_image *stimg)
@@ -231,37 +198,22 @@ dri_st_manager_get_egl_image(struct st_manager *smapi,
/**
* Create a state tracker manager from the given screen.
*/
-struct st_manager *
-dri_create_st_manager(struct dri_screen *screen)
+boolean
+dri_init_st_manager(struct dri_screen *screen)
{
- struct st_manager *smapi;
+ screen->base.screen = screen->pipe_screen;
+ screen->base.get_egl_image = dri_st_manager_get_egl_image;
+ screen->st_api = st_gl_api_create();
- smapi = CALLOC_STRUCT(st_manager);
- if (smapi) {
- smapi->screen = screen->pipe_screen;
- smapi->get_egl_image = dri_st_manager_get_egl_image;
- _dri_get_st_api();
- }
+ if (!screen->st_api)
+ return FALSE;
- return smapi;
+ return TRUE;
}
-/**
- * Destroy a state tracker manager.
- */
void
-dri_destroy_st_manager(struct st_manager *smapi)
-{
- _dri_put_st_api();
- FREE(smapi);
-}
-
-/**
- * Return the st_api of OpenGL state tracker.
- */
-struct st_api *
-dri_get_st_api(void)
+dri_close_st_manager(struct dri_screen *screen)
{
- assert(dri_st_api.stapi);
- return dri_st_api.stapi;
+ if (screen->st_api && screen->st_api->destroy)
+ screen->st_api->destroy(screen->st_api);
}
diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.h b/src/gallium/state_trackers/dri/common/dri_st_api.h
index 11d86cfbdf..0a0d43073c 100644
--- a/src/gallium/state_trackers/dri/common/dri_st_api.h
+++ b/src/gallium/state_trackers/dri/common/dri_st_api.h
@@ -43,14 +43,11 @@ struct __DRIimageRec {
void *loader_private;
};
-struct st_api *
-dri_get_st_api(void);
-
-struct st_manager *
-dri_create_st_manager(struct dri_screen *screen);
+boolean
+dri_init_st_manager(struct dri_screen *screen);
void
-dri_destroy_st_manager(struct st_manager *smapi);
+dri_close_st_manager(struct dri_screen *screen);
struct st_framebuffer_iface *
dri_create_st_framebuffer(struct dri_drawable *drawable);