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 thellst...@vmware.com
---
src/gallium/include/state_tracker/st_api.h | 25 +
.../state_trackers/dri/common/dri_drawable.c |1 +
src/gallium/state_trackers/dri/drm/dri2.c |4 +-
src/gallium/state_trackers/dri/sw/drisw.c |5 +-
src/gallium/state_trackers/egl/common/egl_g3d.c| 13 +--
.../state_trackers/egl/common/egl_g3d_api.c|7 --
src/gallium/state_trackers/egl/common/egl_g3d_st.c |2 +
src/gallium/state_trackers/vega/vg_context.h |5 +-
src/gallium/state_trackers/vega/vg_manager.c | 48 +-
src/gallium/state_trackers/wgl/stw_context.c |6 +-
src/gallium/state_trackers/wgl/stw_st.c|2 +
src/mesa/state_tracker/st_cb_viewport.c| 15 ++-
src/mesa/state_tracker/st_context.h|6 +-
src/mesa/state_tracker/st_manager.c| 98 +++
14 files changed, 121 insertions(+), 116 deletions(-)
diff --git a/src/gallium/include/state_tracker/st_api.h
b/src/gallium/include/state_tracker/st_api.h
index 04fc7c6..f7cc243 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -253,6 +253,12 @@ struct st_context_attribs
struct st_framebuffer_iface
{
/**
+* Atomic stamp which changes when framebuffers need to be updated.
+*/
+
+ int32_t stamp;
+
+ /**
* Available for the state tracker manager to use.
*/
void *st_manager_private;
@@ -315,25 +321,6 @@ struct st_context_iface
void (*destroy)(struct st_context_iface *stctxi);
/**
-* Invalidate the current textures that was taken from a framebuffer.
-*
-* The state tracker manager calls this function to let the rendering
-* context know that it should update the textures it got from
-* st_framebuffer_iface::validate. It should do so at the latest time
possible.
-* Possible right before sending triangles to the pipe context.
-*
-* For certain platforms this function might be called from a thread other
-* than the thread that the context is currently bound in, and must
-* therefore be thread safe. But it is the state tracker manager's
-* responsibility to make sure that the framebuffer is bound to the context
-* and the API context is current for the duration of this call.
-*
-* Thus reducing the sync primitive needed to a single atomic flag.
-*/
- void (*notify_invalid_framebuffer)(struct st_context_iface *stctxi,
- struct st_framebuffer_iface *stfbi);
-
- /**
* Flush all drawing from context to the pipe also flushes the pipe.
*/
void (*flush)(struct st_context_iface *stctxi, unsigned flags,
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c
b/src/gallium/state_trackers/dri/common/dri_drawable.c
index 28a33ac..7b8de31 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 e471e8e..2b6abc3 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 ac11f7c..a1879a8 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 =