Re: [Mesa-dev] [PATCH 1/2] st-api: Rework how drawables are invalidated

2011-06-29 Thread Thomas Hellstrom

Jon,
Thanks for pointing this out. I apparently missed at least one case.
I'll fix ASAP.

/Thomas


On 06/29/2011 02:20 PM, Jon TURNEY wrote:

On 28/06/2011 13:19, Thomas Hellstrom wrote:
   

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.

Signed-off-by: Thomas Hellstromthellst...@vmware.com
---
  src/gallium/include/state_tracker/st_api.h |   26 ++-
  .../state_trackers/dri/common/dri_drawable.c   |3 +
  src/gallium/state_trackers/dri/drm/dri2.c  |4 +-
  src/gallium/state_trackers/dri/sw/drisw.c  |4 +-
  src/gallium/state_trackers/egl/common/egl_g3d.c|   12 +--
  .../state_trackers/egl/common/egl_g3d_api.c|7 --
  src/gallium/state_trackers/egl/common/egl_g3d_st.c |8 ++
  src/gallium/state_trackers/vega/vg_context.h   |4 +-
  src/gallium/state_trackers/vega/vg_manager.c   |   40 --
  src/gallium/state_trackers/wgl/stw_context.c   |6 +-
  src/gallium/state_trackers/wgl/stw_st.c|3 +
  src/mesa/state_tracker/st_cb_viewport.c|   15 +++-
  src/mesa/state_tracker/st_context.h|5 +-
  src/mesa/state_tracker/st_manager.c|   85 +++-
  14 files changed, 109 insertions(+), 113 deletions(-)
 

It looks like state_trackers/glx/xlib (built when ./configured
--with-driver=xlib) hasn't been updated for this change:

make[5]: Entering directory
`/opt/wip/mesa-cygwin-dri-driver/mesa/src/gallium/state_trackers/glx/xlib'
ccache gcc -c -I. -I../../../../../src/gallium/include
-I../../../../../src/gallium/auxiliary -I../../../../../src/gallium/drivers
-I../../../../../include -I../../../../../src/mapi -I../../../../../src/mesa
-I/opt/wip/jhbuild/install/include   -g -O0 -Wall -Wmissing-prototypes
-std=c99 -ffast-math -fno-strict-aliasing -DPTHREADS -DHAVE_POSIX_MEMALIGN
-DUSE_XSHM -DGALLIUM_LLVMPIPE -D__STDC_CONSTANT_MACROS -DHAVE_LLVM=0x0208
-I/usr/include  -DNDEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS xm_api.c -o xm_api.o
xm_api.c: In function ‘xmesa_notify_invalid_buffer’:
xm_api.c:1119:16: error: ‘struct st_context_iface’ has no member named
‘notify_invalid_framebuffer’
make[5]: *** [xm_api.o] Error 1
make[5]: Leaving directory
`/opt/wip/mesa-cygwin-dri-driver/mesa/src/gallium/state_trackers/glx/xlib'
   


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] st-api: Rework how drawables are invalidated

2011-06-28 Thread Jose Fonseca
Looks good to me Thomas.

Jose

- Original Message -
 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.
 
 Signed-off-by: Thomas Hellstrom thellst...@vmware.com
 ---
  src/gallium/include/state_tracker/st_api.h |   26 ++-
  .../state_trackers/dri/common/dri_drawable.c   |3 +
  src/gallium/state_trackers/dri/drm/dri2.c  |4 +-
  src/gallium/state_trackers/dri/sw/drisw.c  |4 +-
  src/gallium/state_trackers/egl/common/egl_g3d.c|   12 +--
  .../state_trackers/egl/common/egl_g3d_api.c|7 --
  src/gallium/state_trackers/egl/common/egl_g3d_st.c |8 ++
  src/gallium/state_trackers/vega/vg_context.h   |4 +-
  src/gallium/state_trackers/vega/vg_manager.c   |   40 --
  src/gallium/state_trackers/wgl/stw_context.c   |6 +-
  src/gallium/state_trackers/wgl/stw_st.c|3 +
  src/mesa/state_tracker/st_cb_viewport.c|   15 +++-
  src/mesa/state_tracker/st_context.h|5 +-
  src/mesa/state_tracker/st_manager.c|   85
  +++-
  14 files changed, 109 insertions(+), 113 deletions(-)
 
 diff --git a/src/gallium/include/state_tracker/st_api.h
 b/src/gallium/include/state_tracker/st_api.h
 index 04fc7c6..b08972f 100644
 --- a/src/gallium/include/state_tracker/st_api.h
 +++ b/src/gallium/include/state_tracker/st_api.h
 @@ -253,6 +253,13 @@ struct st_context_attribs
  struct st_framebuffer_iface
  {
 /**
 +* Atomic flag to indicate invalid status, which can only be
 resolved
 +* by a call to validate.
 +*/
 +
 +   int32_t invalid;
 +
 +   /**
  * Available for the state tracker manager to use.
  */
 void *st_manager_private;
 @@ -315,25 +322,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..09d25bc 100644
 --- a/src/gallium/state_trackers/dri/common/dri_drawable.c
 +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
 @@ -82,6 +82,8 @@ dri_st_framebuffer_validate(struct
 st_framebuffer_iface *stfbi,
drawable-texture_mask = statt_mask;
 }
  
 +   p_atomic_set(drawable-base.invalid, FALSE);
 +
 if (!out)
return TRUE;
  
 @@ -136,6 +138,7 @@ dri_create_buffer(__DRIscreen * sPriv,
 drawable-sPriv = sPriv;
 drawable-dPriv = dPriv;
 dPriv-driverPrivate = (void *)drawable;
 +   p_atomic_set(drawable-base.invalid, TRUE);
  
 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..9e61d7e 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_set(drawable-base.invalid, TRUE);
  }
  
  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..f9ba971 100644
 --- a/src/gallium/state_trackers/dri/sw/drisw.c
 +++ 

Re: [Mesa-dev] [PATCH 1/2] st-api: Rework how drawables are invalidated

2011-06-28 Thread Thomas Hellstrom

On 06/28/2011 04:27 PM, Jose Fonseca wrote:

Looks good to me Thomas.

Jose
   


Jakob pointed out that the state trackers (vega  mesa) will actually 
create a window system draw buffer / framebuffer per context, even if 
they represent the same window system drawable, so I need to do some 
fixups to accound for that.


/Thomas


- Original Message -
   

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.

Signed-off-by: Thomas Hellstromthellst...@vmware.com
---
  src/gallium/include/state_tracker/st_api.h |   26 ++-
  .../state_trackers/dri/common/dri_drawable.c   |3 +
  src/gallium/state_trackers/dri/drm/dri2.c  |4 +-
  src/gallium/state_trackers/dri/sw/drisw.c  |4 +-
  src/gallium/state_trackers/egl/common/egl_g3d.c|   12 +--
  .../state_trackers/egl/common/egl_g3d_api.c|7 --
  src/gallium/state_trackers/egl/common/egl_g3d_st.c |8 ++
  src/gallium/state_trackers/vega/vg_context.h   |4 +-
  src/gallium/state_trackers/vega/vg_manager.c   |   40 --
  src/gallium/state_trackers/wgl/stw_context.c   |6 +-
  src/gallium/state_trackers/wgl/stw_st.c|3 +
  src/mesa/state_tracker/st_cb_viewport.c|   15 +++-
  src/mesa/state_tracker/st_context.h|5 +-
  src/mesa/state_tracker/st_manager.c|   85
  +++-
  14 files changed, 109 insertions(+), 113 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h
b/src/gallium/include/state_tracker/st_api.h
index 04fc7c6..b08972f 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -253,6 +253,13 @@ struct st_context_attribs
  struct st_framebuffer_iface
  {
 /**
+* Atomic flag to indicate invalid status, which can only be
resolved
+* by a call to validate.
+*/
+
+   int32_t invalid;
+
+   /**
  * Available for the state tracker manager to use.
  */
 void *st_manager_private;
@@ -315,25 +322,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..09d25bc 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -82,6 +82,8 @@ dri_st_framebuffer_validate(struct
st_framebuffer_iface *stfbi,
drawable-texture_mask = statt_mask;
 }

+   p_atomic_set(drawable-base.invalid, FALSE);
+
 if (!out)
return TRUE;

@@ -136,6 +138,7 @@ dri_create_buffer(__DRIscreen * sPriv,
 drawable-sPriv = sPriv;
 drawable-dPriv = dPriv;
 dPriv-driverPrivate = (void *)drawable;
+   p_atomic_set(drawable-base.invalid, TRUE);

 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..9e61d7e 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_set(drawable-base.invalid, TRUE);
  }

  static const __DRI2flushExtension dri2FlushExtension = {
diff --git 

Re: [Mesa-dev] [PATCH 1/2] st-api: Rework how drawables are invalidated

2011-06-28 Thread Chia-I Wu
On Tue, Jun 28, 2011 at 9:19 PM, Thomas Hellstrom thellst...@vmware.com wrote:
 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.
This looks great.

Just one question.  Would it make things easier for mesa and vega if
we have st_framebuffer_iface::stamp instead of
st_framebuffer_iface::invalid?

 Signed-off-by: Thomas Hellstrom thellst...@vmware.com
 ---
  src/gallium/include/state_tracker/st_api.h         |   26 ++-
  .../state_trackers/dri/common/dri_drawable.c       |    3 +
  src/gallium/state_trackers/dri/drm/dri2.c          |    4 +-
  src/gallium/state_trackers/dri/sw/drisw.c          |    4 +-
  src/gallium/state_trackers/egl/common/egl_g3d.c    |   12 +--
  .../state_trackers/egl/common/egl_g3d_api.c        |    7 --
  src/gallium/state_trackers/egl/common/egl_g3d_st.c |    8 ++
  src/gallium/state_trackers/vega/vg_context.h       |    4 +-
  src/gallium/state_trackers/vega/vg_manager.c       |   40 --
  src/gallium/state_trackers/wgl/stw_context.c       |    6 +-
  src/gallium/state_trackers/wgl/stw_st.c            |    3 +
  src/mesa/state_tracker/st_cb_viewport.c            |   15 +++-
  src/mesa/state_tracker/st_context.h                |    5 +-
  src/mesa/state_tracker/st_manager.c                |   85 
 +++-
  14 files changed, 109 insertions(+), 113 deletions(-)

 diff --git a/src/gallium/include/state_tracker/st_api.h 
 b/src/gallium/include/state_tracker/st_api.h
 index 04fc7c6..b08972f 100644
 --- a/src/gallium/include/state_tracker/st_api.h
 +++ b/src/gallium/include/state_tracker/st_api.h
 @@ -253,6 +253,13 @@ struct st_context_attribs
  struct st_framebuffer_iface
  {
    /**
 +    * Atomic flag to indicate invalid status, which can only be resolved
 +    * by a call to validate.
 +    */
 +
 +   int32_t invalid;
 +
 +   /**
     * Available for the state tracker manager to use.
     */
    void *st_manager_private;
 @@ -315,25 +322,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..09d25bc 100644
 --- a/src/gallium/state_trackers/dri/common/dri_drawable.c
 +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
 @@ -82,6 +82,8 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface 
 *stfbi,
       drawable-texture_mask = statt_mask;
    }

 +   p_atomic_set(drawable-base.invalid, FALSE);
 +
    if (!out)
       return TRUE;

 @@ -136,6 +138,7 @@ dri_create_buffer(__DRIscreen * sPriv,
    drawable-sPriv = sPriv;
    drawable-dPriv = dPriv;
    dPriv-driverPrivate = (void *)drawable;
 +   p_atomic_set(drawable-base.invalid, TRUE);

    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..9e61d7e 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_set(drawable-base.invalid, TRUE);
  }

  static const __DRI2flushExtension dri2FlushExtension = {
 diff --git a/src/gallium/state_trackers/dri/sw/drisw.c