[Mesa-dev] [PATCH v2 09/21] mesa/samplerobj: Set state dirty in bind if state is shared

Eric Anholt eric at anholt.net
Tue Jun 19 11:02:54 PDT 2012


On Tue, 12 Jun 2012 21:38:49 +0300, Pauli Nieminen <pauli.nieminen at linux.intel.com> wrote:
> State changes in share group must be updated when the object is rebound
> to the binding point. That requires mesa to set texture state dirty when
> binding sampler object in a share group.
> 
> GL 4.2 specification appendix "Shared Objects and Multiple Contexts"
> D3.3 Rule 4:
> "If the contents of an object T are changed in a context other than the
> current context, T must be attached or re-attached to at least one binding
> point in the current context, or at least one attachment point of a
> currently bound container object C, in order to guarantee that the new
> contents of T are visible in the current context."
> 
> Signed-off-by: Pauli Nieminen <pauli.nieminen at linux.intel.com>
> ---
>  src/mesa/main/samplerobj.c |   14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
> index f276296..fdd50ed 100644
> --- a/src/mesa/main/samplerobj.c
> +++ b/src/mesa/main/samplerobj.c
> @@ -267,11 +267,19 @@ _mesa_BindSampler(GLuint unit, GLuint sampler)
>           return;
>        }
>     }
> -   
> -   if (ctx->Texture.Unit[unit].Sampler != sampObj) {
> -      FLUSH_VERTICES(ctx, _NEW_TEXTURE);
> +
> +   /* No need to flush if binding same sampler and context is not shared */
> +   if (ctx->Texture.Unit[unit].Sampler == sampObj) {
> +      GLboolean early_out;
> +      _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
> +      early_out = (ctx->Shared->RefCount == 1);
> +      _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
> +      if (early_out)
> +         return;

I don't think the locking is doing anything of use here.  We're not
protecting from a race where the shared context goes away in parallel
with us making this decision, because it could have just happened before
the sampler equality test.

The glBindTexture shared context early out has the same problem in a
slightly different style.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120619/9c54ea43/attachment.pgp>


More information about the mesa-dev mailing list