summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorThomas Hellstrom <[email protected]>2011-06-29 09:00:23 +0200
committerThomas Hellstrom <[email protected]>2011-06-29 12:48:59 +0200
commitac8fdbc1c723afb19eeaba5457ba78d0bf33b8d4 (patch)
tree34b7c9d72551aa7976d634738585d65a256760ae /src/gallium/state_trackers
parent1a7e17e44a1129bbd6a0f454fe95b3ce8240cd45 (diff)
st-api: Rework how drawables are invalidated v3.
The api and the state tracker manager code as well as the state tracker code assumed that only a single context could be bound to a drawable. That is not a valid assumption, since multiple contexts can bind to the same drawable. Fix this by making it the state tracker's responsibility to update all contexts binding to a drawable Note that the state trackers themselves don't use atomic stamps on frame-buffers. Multiple context rendering to the same drawable should be protected by the application. Signed-off-by: Thomas Hellstrom <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/dri/common/dri_drawable.c1
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c4
-rw-r--r--src/gallium/state_trackers/dri/sw/drisw.c5
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c13
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_api.c7
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_st.c2
-rw-r--r--src/gallium/state_trackers/vega/vg_context.h5
-rw-r--r--src/gallium/state_trackers/vega/vg_manager.c48
-rw-r--r--src/gallium/state_trackers/wgl/stw_context.c6
-rw-r--r--src/gallium/state_trackers/wgl/stw_st.c2
10 files changed, 42 insertions, 51 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c
index 28a33ac7d07..7b8de3174be 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -136,6 +136,7 @@ dri_create_buffer(__DRIscreen * sPriv,
drawable->sPriv = sPriv;
drawable->dPriv = dPriv;
dPriv->driverPrivate = (void *)drawable;
+ p_atomic_set(&drawable->base.stamp, 1);
return GL_TRUE;
fail:
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 0296a78092a..fe4ddb312be 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -52,13 +52,11 @@ static void
dri2_invalidate_drawable(__DRIdrawable *dPriv)
{
struct dri_drawable *drawable = dri_drawable(dPriv);
- struct dri_context *ctx = drawable->context;
dri2InvalidateDrawable(dPriv);
drawable->dPriv->lastStamp = *drawable->dPriv->pStamp;
- if (ctx)
- ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base);
+ p_atomic_inc(&drawable->base.stamp);
}
static const __DRI2flushExtension dri2FlushExtension = {
diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
index ac11f7c47f6..a1879a8f46a 100644
--- a/src/gallium/state_trackers/dri/sw/drisw.c
+++ b/src/gallium/state_trackers/dri/sw/drisw.c
@@ -103,14 +103,11 @@ drisw_present_texture(__DRIdrawable *dPriv,
static INLINE void
drisw_invalidate_drawable(__DRIdrawable *dPriv)
{
- struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv);
struct dri_drawable *drawable = dri_drawable(dPriv);
drawable->texture_stamp = dPriv->lastStamp - 1;
- /* check if swapping currently bound buffer */
- if (ctx && ctx->dPriv == dPriv)
- ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base);
+ p_atomic_inc(&drawable->base.stamp);
}
static INLINE void
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 7d1eafe3bec..6649f02b244 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -31,6 +31,7 @@
#include "util/u_memory.h"
#include "util/u_format.h"
#include "util/u_string.h"
+#include "util/u_atomic.h"
#include "egl_g3d.h"
#include "egl_g3d_api.h"
@@ -45,15 +46,9 @@ egl_g3d_invalid_surface(struct native_display *ndpy,
{
/* XXX not thread safe? */
struct egl_g3d_surface *gsurf = egl_g3d_surface(nsurf->user_data);
- struct egl_g3d_context *gctx;
-
- /*
- * Some functions such as egl_g3d_copy_buffers create a temporary native
- * surface. There is no gsurf associated with it.
- */
- gctx = (gsurf) ? egl_g3d_context(gsurf->base.CurrentContext) : NULL;
- if (gctx)
- gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi, gsurf->stfbi);
+
+ if (gsurf && gsurf->stfbi)
+ p_atomic_inc(&gsurf->stfbi->stamp);
}
static struct pipe_screen *
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
index cd68e97023b..f897054a540 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
@@ -504,19 +504,12 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy,
(gdraw) ? gdraw->stfbi : NULL, (gread) ? gread->stfbi : NULL);
if (ok) {
if (gdraw) {
- gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi,
- gdraw->stfbi);
-
if (gdraw->base.Type == EGL_WINDOW_BIT) {
gctx->base.WindowRenderBuffer =
(gdraw->stvis.render_buffer == ST_ATTACHMENT_FRONT_LEFT) ?
EGL_SINGLE_BUFFER : EGL_BACK_BUFFER;
}
}
- if (gread && gread != gdraw) {
- gctx->stctxi->notify_invalid_framebuffer(gctx->stctxi,
- gread->stfbi);
- }
}
}
else if (old_gctx) {
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
index 2b944b521a4..60c3e332ac9 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
@@ -292,6 +292,8 @@ egl_g3d_create_st_framebuffer(_EGLSurface *surf)
return NULL;
stfbi->visual = &gsurf->stvis;
+ p_atomic_set(&stfbi->stamp, 1);
+
if (gsurf->base.Type != EGL_PBUFFER_BIT) {
stfbi->flush_front = egl_g3d_st_framebuffer_flush_front;
stfbi->validate = egl_g3d_st_framebuffer_validate;
diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h
index 71491a5aa22..d91ee9797f1 100644
--- a/src/gallium/state_trackers/vega/vg_context.h
+++ b/src/gallium/state_trackers/vega/vg_context.h
@@ -65,6 +65,8 @@ struct st_framebuffer {
enum st_attachment_type strb_att;
void *privateData;
+ int32_t stamp;
+ int32_t iface_stamp;
};
enum vg_object_type {
@@ -105,7 +107,6 @@ struct vg_context
VGErrorCode _error;
struct st_framebuffer *draw_buffer;
- int32_t draw_buffer_invalid;
struct cso_hash *owned_objects[VG_OBJECT_LAST];
@@ -129,6 +130,8 @@ struct vg_context
struct vg_paint *default_paint;
struct blit_state *blit;
+
+ int32_t draw_stamp;
};
diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c
index eeea68677de..dec1581fb84 100644
--- a/src/gallium/state_trackers/vega/vg_manager.c
+++ b/src/gallium/state_trackers/vega/vg_manager.c
@@ -106,35 +106,38 @@ vg_manager_validate_framebuffer(struct vg_context *ctx)
{
struct st_framebuffer *stfb = ctx->draw_buffer;
struct pipe_resource *pt;
+ int32_t new_stamp;
/* no binding surface */
if (!stfb)
return;
- if (!p_atomic_read(&ctx->draw_buffer_invalid))
- return;
+ new_stamp = p_atomic_read(&stfb->iface->stamp);
+ if (stfb->iface_stamp != new_stamp) {
+ do {
+ /* validate the fb */
+ if (!stfb->iface->validate(stfb->iface, &stfb->strb_att,
+ 1, &pt) || !pt)
+ return;
- /* validate the fb */
- if (!stfb->iface->validate(stfb->iface, &stfb->strb_att, 1, &pt) || !pt)
- return;
+ stfb->iface_stamp = new_stamp;
+ new_stamp = p_atomic_read(&stfb->iface->stamp);
- p_atomic_set(&ctx->draw_buffer_invalid, FALSE);
+ } while (stfb->iface_stamp != new_stamp);
- if (vg_context_update_color_rb(ctx, pt) ||
- stfb->width != pt->width0 ||
- stfb->height != pt->height0)
- ctx->state.dirty |= FRAMEBUFFER_DIRTY;
+ if (vg_context_update_color_rb(ctx, pt) ||
+ stfb->width != pt->width0 ||
+ stfb->height != pt->height0)
+ ++stfb->stamp;
- stfb->width = pt->width0;
- stfb->height = pt->height0;
-}
+ stfb->width = pt->width0;
+ stfb->height = pt->height0;
+ }
-static void
-vg_context_notify_invalid_framebuffer(struct st_context_iface *stctxi,
- struct st_framebuffer_iface *stfbi)
-{
- struct vg_context *ctx = (struct vg_context *) stctxi;
- p_atomic_set(&ctx->draw_buffer_invalid, TRUE);
+ if (ctx->draw_stamp != stfb->stamp) {
+ ctx->state.dirty |= FRAMEBUFFER_DIRTY;
+ ctx->draw_stamp = stfb->stamp;
+ }
}
static void
@@ -187,8 +190,6 @@ vg_api_create_context(struct st_api *stapi, struct st_manager *smapi,
ctx->iface.destroy = vg_context_destroy;
- ctx->iface.notify_invalid_framebuffer =
- vg_context_notify_invalid_framebuffer;
ctx->iface.flush = vg_context_flush;
ctx->iface.teximage = NULL;
@@ -266,8 +267,6 @@ vg_context_bind_framebuffers(struct st_context_iface *stctxi,
if (stdrawi != streadi)
return FALSE;
- p_atomic_set(&ctx->draw_buffer_invalid, TRUE);
-
strb_att = (stdrawi) ? choose_attachment(stdrawi) : ST_ATTACHMENT_INVALID;
if (ctx->draw_buffer) {
@@ -313,11 +312,14 @@ vg_context_bind_framebuffers(struct st_context_iface *stctxi,
stfb->width = 0;
stfb->height = 0;
stfb->strb_att = strb_att;
+ stfb->stamp = 1;
+ stfb->iface_stamp = p_atomic_read(&stdrawi->stamp) - 1;
ctx->draw_buffer = stfb;
}
ctx->draw_buffer->iface = stdrawi;
+ ctx->draw_stamp = ctx->draw_buffer->stamp - 1;
return TRUE;
}
diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c
index 5608d4f4ce7..c2839fe815f 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -31,6 +31,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/u_memory.h"
+#include "util/u_atomic.h"
#include "state_tracker/st_api.h"
#include "stw_icd.h"
@@ -361,10 +362,7 @@ stw_flush_current_locked( struct stw_framebuffer *fb )
void
stw_notify_current_locked( struct stw_framebuffer *fb )
{
- struct stw_context *ctx = stw_current_context();
-
- if (ctx && ctx->current_framebuffer == fb)
- ctx->st->notify_invalid_framebuffer(ctx->st, fb->stfb);
+ p_atomic_inc(&fb->stfb->stamp);
}
/**
diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c
index 9174533fc06..28c93f4fb57 100644
--- a/src/gallium/state_trackers/wgl/stw_st.c
+++ b/src/gallium/state_trackers/wgl/stw_st.c
@@ -27,6 +27,7 @@
#include "util/u_memory.h"
#include "util/u_inlines.h"
+#include "util/u_atomic.h"
#include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
#include "stw_st.h"
@@ -196,6 +197,7 @@ stw_st_create_framebuffer(struct stw_framebuffer *fb)
stwfb->stvis = fb->pfi->stvis;
stwfb->base.visual = &stwfb->stvis;
+ p_atomic_set(&stwfb->base.stamp, 1);
stwfb->base.flush_front = stw_st_framebuffer_flush_front;
stwfb->base.validate = stw_st_framebuffer_validate;