diff options
author | Thomas Hellstrom <thellstrom-at-vmware-dot-com> | 2009-04-28 11:49:39 +0200 |
---|---|---|
committer | Thomas Hellstrom <thellstrom-at-vmware-dot-com> | 2009-04-28 11:50:40 +0200 |
commit | ca1f5f7e6c05e34cfe8ef10f29aa19f5547311e6 (patch) | |
tree | a363f9f7b0cfe8b140f20e5cf91b4fcfbd0f606e /src/gallium/state_trackers/dri/dri_context.c | |
parent | a70c4f352e8e7aea0b130fd1285352bbf89503b5 (diff) |
gallium: Update the dri2 state tracker to support dri1.
Signed-off-by: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
Diffstat (limited to 'src/gallium/state_trackers/dri/dri_context.c')
-rw-r--r-- | src/gallium/state_trackers/dri/dri_context.c | 91 |
1 files changed, 76 insertions, 15 deletions
diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 92c26ac70f..a45fb541fd 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -32,9 +32,8 @@ #include "dri_screen.h" #include "dri_drawable.h" - - #include "state_tracker/drm_api.h" +#include "state_tracker/dri1_api.h" #include "state_tracker/st_public.h" #include "state_tracker/st_context.h" #include "pipe/p_context.h" @@ -44,6 +43,7 @@ #include "util/u_memory.h" + GLboolean dri_create_context(const __GLcontextModes *visual, __DRIcontextPrivate *cPriv, @@ -65,6 +65,9 @@ dri_create_context(const __GLcontextModes *visual, cPriv->driverPrivate = ctx; ctx->cPriv = cPriv; ctx->sPriv = sPriv; + ctx->lock = screen->drmLock; + ctx->d_stamp = -1; + ctx->r_stamp = -1; driParseConfigFiles(&ctx->optionCache, &screen->optionCache, @@ -126,13 +129,22 @@ dri_destroy_context(__DRIcontextPrivate *cPriv) GLboolean dri_unbind_context(__DRIcontextPrivate *cPriv) { - struct dri_context *ctx = dri_context(cPriv); - st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - /* XXX make_current(NULL)? */ + if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + + if (--ctx->bind_count == 0) { + GET_CURRENT_CONTEXT(curGLCtx); + + if (ctx->st == curGLCtx->st) { + st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + st_make_current(NULL, NULL, NULL); + } + } + } + return GL_TRUE; } - GLboolean dri_make_current(__DRIcontextPrivate *cPriv, __DRIdrawablePrivate *driDrawPriv, @@ -143,23 +155,32 @@ dri_make_current(__DRIcontextPrivate *cPriv, struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); struct dri_drawable *draw = dri_drawable(driDrawPriv); struct dri_drawable *read = dri_drawable(driReadPriv); + GET_CURRENT_CONTEXT(oldGLCtx); + + if (oldGLCtx && oldGLCtx->st != ctx->st) + st_flush(oldGLCtx->st, PIPE_FLUSH_RENDER_CACHE, NULL); + + ++ctx->bind_count; /* This is for situations in which we need a rendering context but * there may not be any currently bound. */ screen->dummyContext = ctx; - st_make_current(ctx->st, - draw->stfb, - read->stfb); - /* used in dri_flush_frontbuffer */ ctx->dPriv = driDrawPriv; - - if (driDrawPriv) - dri_get_buffers(driDrawPriv); - if (driDrawPriv != driReadPriv && driReadPriv) - dri_get_buffers(driReadPriv); + ctx->rPriv = driReadPriv; + + st_make_current(ctx->st, draw->stfb, read->stfb); + + if (__dri1_api_hooks) { + dri1_update_drawables(ctx, draw, read); + } else { + if (driDrawPriv) + dri_get_buffers(driDrawPriv); + if (driDrawPriv != driReadPriv && driReadPriv) + dri_get_buffers(driReadPriv); + } } else { st_make_current(NULL, NULL, NULL); } @@ -167,4 +188,44 @@ dri_make_current(__DRIcontextPrivate *cPriv, return GL_TRUE; } +static void +st_dri_lock(struct pipe_context *pipe) +{ + dri_lock((struct dri_context *) pipe->priv); +} + +static void +st_dri_unlock(struct pipe_context *pipe) +{ + dri_unlock((struct dri_context *) pipe->priv); +} + +static boolean +st_dri_is_locked(struct pipe_context *pipe) +{ + return ((struct dri_context *) pipe->priv)->isLocked; +} + +static boolean +st_dri_lost_lock(struct pipe_context *pipe) +{ + return ((struct dri_context *) pipe->priv)->wsLostLock; +} + +static void +st_dri_clear_lost_lock(struct pipe_context *pipe) +{ + ((struct dri_context *) pipe->priv)->wsLostLock = FALSE; +} + +struct dri1_api_lock_funcs dri1_lf = +{ + .lock = st_dri_lock, + .unlock = st_dri_unlock, + .is_locked = st_dri_is_locked, + .is_lock_lost = st_dri_lost_lock, + .clear_lost_lock = st_dri_clear_lost_lock +}; + + /* vim: set sw=3 ts=8 sts=3 expandtab: */ |