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

Pauli Nieminen pauli.nieminen at linux.intel.com
Tue Jun 12 11:38:49 PDT 2012


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;
    }
 
+   FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+
    /* bind new sampler */
    _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler,
                                   sampObj);
-- 
1.7.9.5



More information about the mesa-dev mailing list