From 3e38dbe3d3371f0a37dd35582301ae2b1507e5d2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 09:22:02 +0000 Subject: [PATCH] gallium: plumb winsys-drawable-handle through to state tracker The state trackers need this value so that they can supply it as the "void *" argument to flush_frontbuffer. Fixes single-buffer rendering. --- src/gallium/state_trackers/dri/dri_context.c | 12 +++++++++--- src/gallium/state_trackers/egl/common/egl_g3d.c | 9 +++++++-- .../state_trackers/egl/common/st_public_tmp.h | 2 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 5 +++-- src/gallium/state_trackers/vega/vg_tracker.c | 10 +++++++++- src/gallium/state_trackers/vega/vg_tracker.h | 3 ++- src/gallium/state_trackers/wgl/stw_context.c | 6 +++--- src/mesa/state_tracker/st_context.c | 8 ++++++-- src/mesa/state_tracker/st_public.h | 3 ++- 9 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 908cef454e9..2f991c39e33 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -128,7 +128,7 @@ dri_unbind_context(__DRIcontext * cPriv) if (--ctx->bind_count == 0) { if (ctx->st && ctx->st == st_get_current()) { st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - st_make_current(NULL, NULL, NULL); + st_make_current(NULL, NULL, NULL, NULL); } } } @@ -161,7 +161,13 @@ dri_make_current(__DRIcontext * cPriv, ctx->r_stamp = driReadPriv->lastStamp - 1; } - st_make_current(ctx->st, draw->stfb, read->stfb); + /* DRI co-state tracker currently overrides flush_frontbuffer. + * When this is fixed, will need to pass the drawable in the + * fourth parameter here so that when Mesa calls + * flush_frontbuffer directly (in front-buffer rendering), it + * will have access to the drawable argument: + */ + st_make_current(ctx->st, draw->stfb, read->stfb, NULL); if (__dri1_api_hooks) { dri1_update_drawables(ctx, draw, read); @@ -170,7 +176,7 @@ dri_make_current(__DRIcontext * cPriv, ctx->pipe->priv); } } else { - st_make_current(NULL, NULL, NULL); + st_make_current(NULL, NULL, NULL, NULL); } return GL_TRUE; diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index f54c51a6681..e4972d493d6 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -892,8 +892,13 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, if (gctx) { ok = egl_g3d_realloc_context(dpy, &gctx->base); if (ok) { + /* XXX: need to pass the winsys argument for + * flush_frontbuffer in the fourth parameter here: + */ ok = gctx->stapi->st_make_current(gctx->st_ctx, - gctx->draw.st_fb, gctx->read.st_fb); + gctx->draw.st_fb, + gctx->read.st_fb, + NULL); if (ok) { egl_g3d_validate_context(dpy, &gctx->base); if (gdraw->base.Type == EGL_WINDOW_BIT) { @@ -905,7 +910,7 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, } } else if (old_gctx) { - ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL); + ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL, NULL); old_gctx->base.WindowRenderBuffer = EGL_NONE; } diff --git a/src/gallium/state_trackers/egl/common/st_public_tmp.h b/src/gallium/state_trackers/egl/common/st_public_tmp.h index 507a0ec4027..562dd68c150 100644 --- a/src/gallium/state_trackers/egl/common/st_public_tmp.h +++ b/src/gallium/state_trackers/egl/common/st_public_tmp.h @@ -9,7 +9,7 @@ ST_PUBLIC(st_get_framebuffer_surface, int, struct st_f ST_PUBLIC(st_get_framebuffer_texture, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) ST_PUBLIC(st_framebuffer_private, void *, struct st_framebuffer *stfb) ST_PUBLIC(st_unreference_framebuffer, void, struct st_framebuffer *stfb) -ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read) +ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read, void *winsys_drawable_handle) ST_PUBLIC(st_get_current, struct st_context *, void) ST_PUBLIC(st_flush, void, struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence) ST_PUBLIC(st_finish, void, struct st_context *st) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 568bc6e9622..f4d7133d2ff 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -1020,7 +1020,8 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, c->xm_buffer = drawBuffer; c->xm_read_buffer = readBuffer; - st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb); + st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb, + &drawBuffer->ws); xmesa_check_and_update_buffer_size(c, drawBuffer); if (readBuffer != drawBuffer) @@ -1031,7 +1032,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, } else { /* Detach */ - st_make_current( NULL, NULL, NULL ); + st_make_current( NULL, NULL, NULL, NULL ); } return GL_TRUE; diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index 57d3baad7fb..a002e50faf7 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -376,11 +376,19 @@ void st_unreference_framebuffer(struct st_framebuffer *stfb) boolean st_make_current(struct vg_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read) + struct st_framebuffer *read, + void *winsys_drawable_handle) { vg_set_current_context(st); if (st) { st->draw_buffer = draw; + + /* VG state tracker doesn't seem to do front-buffer rendering + * (no calls to flush_frontbuffer). If it ever did start doing + * that, it would need to pass this value down in the + * flush_frontbuffer call: + */ + st->pipe->priv = winsys_drawable_handle; } return VG_TRUE; } diff --git a/src/gallium/state_trackers/vega/vg_tracker.h b/src/gallium/state_trackers/vega/vg_tracker.h index c1196954a76..165a6b7a332 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.h +++ b/src/gallium/state_trackers/vega/vg_tracker.h @@ -101,7 +101,8 @@ void st_unreference_framebuffer(struct st_framebuffer *stfb); PUBLIC boolean st_make_current(struct vg_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read); + struct st_framebuffer *read, + void *winsys_drawable_handle); PUBLIC struct vg_context *st_get_current(void); diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index 05ccd5febcf..866f485a408 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -226,7 +226,7 @@ DrvDeleteContext( /* Unbind current if deleting current context. */ if (curctx == ctx) - st_make_current( NULL, NULL, NULL ); + st_make_current( NULL, NULL, NULL, NULL ); st_destroy_context(ctx->st); FREE(ctx); @@ -317,7 +317,7 @@ stw_make_current( } if (hdc == NULL || dhglrc == 0) { - return st_make_current( NULL, NULL, NULL ); + return st_make_current( NULL, NULL, NULL, NULL ); } pipe_mutex_lock( stw_dev->ctx_mutex ); @@ -352,7 +352,7 @@ stw_make_current( /* pass to stw_flush_frontbuffer as context_private */ ctx->st->pipe->priv = hdc; - if(!st_make_current( ctx->st, fb->stfb, fb->stfb )) + if(!st_make_current( ctx->st, fb->stfb, fb->stfb, hdc )) goto fail; success: diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 0358a707261..09f891d691a 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -272,7 +272,8 @@ void st_destroy_context( struct st_context *st ) GLboolean st_make_current(struct st_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read) + struct st_framebuffer *read, + void *winsys_drawable_handle ) { /* Call this periodically to detect when the user has begun using * GL rendering from multiple threads. @@ -280,10 +281,13 @@ st_make_current(struct st_context *st, _glapi_check_multithread(); if (st) { - if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) + if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) { + st->pipe->priv = NULL; return GL_FALSE; + } _mesa_check_init_viewport(st->ctx, draw->InitWidth, draw->InitHeight); + st->pipe->priv = winsys_drawable_handle; return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 0824356cecc..4b40d6d0448 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -105,7 +105,8 @@ void st_unreference_framebuffer( struct st_framebuffer *stfb ); PUBLIC GLboolean st_make_current(struct st_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read); + struct st_framebuffer *read, + void *winsys_drawable_handle); PUBLIC struct st_context *st_get_current(void); -- 2.30.2