diff options
author | Jakob Bornecrantz <[email protected]> | 2010-04-24 11:08:58 +0100 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2010-04-26 00:40:17 +0100 |
commit | a66b391edf746a5eb0cb4aad1ff2e546df00a11d (patch) | |
tree | 7aca97c5795a5ddf946c4397ff15ff00e5a66631 /src/gallium | |
parent | ea6a52a1f8e7fd72b5506218c31e58088131f1f5 (diff) |
st/dri: Make st_manager the base for dri_screen
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_context.c | 15 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_context.h | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_screen.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_screen.h | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_st_api.c | 70 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/common/dri_st_api.h | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/drm/dri1.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/sw/drisw.c | 6 |
8 files changed, 35 insertions, 85 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c index f14f4130bf4..97e3b0628f1 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 594618874a4..9fe6b581016 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 4bfbc6e80b7..7060107e737 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 6e814af615e..98cb9e75508 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 9702acea5c8..6c8a7e82abe 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 11d86cfbdf7..0a0d43073cb 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); diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c index 0be5fb5d8da..3f6f930edef 100644 --- a/src/gallium/state_trackers/dri/drm/dri1.c +++ b/src/gallium/state_trackers/dri/drm/dri1.c @@ -257,7 +257,7 @@ static void dri1_flush_frontbuffer(struct dri_drawable *draw, enum st_attachment_type statt) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(draw->sPriv); struct dri_screen *screen = dri_screen(draw->sPriv); struct pipe_screen *pipe_screen = screen->pipe_screen; struct pipe_fence_handle *dummy_fence; @@ -280,8 +280,8 @@ dri1_flush_frontbuffer(struct dri_drawable *draw, void dri1_swap_buffers(__DRIdrawable * dPriv) { - struct dri_context *ctx = dri_get_current(); struct dri_drawable *draw = dri_drawable(dPriv); + struct dri_context *ctx = dri_get_current(draw->sPriv); struct dri_screen *screen = dri_screen(draw->sPriv); struct pipe_screen *pipe_screen = screen->pipe_screen; struct pipe_fence_handle *fence; @@ -309,7 +309,7 @@ dri1_swap_buffers(__DRIdrawable * dPriv) void dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv); struct dri_screen *screen = dri_screen(dPriv->driScreenPriv); struct pipe_screen *pipe_screen = screen->pipe_screen; struct drm_clip_rect sub_bbox; diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index a7f16dc6929..9bd838e6227 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -105,7 +105,7 @@ drisw_present_texture(__DRIdrawable *dPriv, static INLINE void drisw_invalidate_drawable(__DRIdrawable *dPriv) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv); struct dri_drawable *drawable = dri_drawable(dPriv); drawable->texture_stamp = dPriv->lastStamp - 1; @@ -131,7 +131,7 @@ drisw_copy_to_front(__DRIdrawable * dPriv, void drisw_swap_buffers(__DRIdrawable *dPriv) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv); struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_resource *ptex; @@ -151,7 +151,7 @@ static void drisw_flush_frontbuffer(struct dri_drawable *drawable, enum st_attachment_type statt) { - struct dri_context *ctx = dri_get_current(); + struct dri_context *ctx = dri_get_current(drawable->sPriv); struct pipe_resource *ptex; if (!ctx) |