[Mesa-dev] [PATCH] Unreference sampler object when it's currently bound to, texture unit.

Brian Paul brianp at vmware.com
Wed Mar 6 09:11:08 PST 2013


On 03/06/2013 09:15 AM, Alan Hourihane wrote:

 > This change specifically unbinds a sampler object from the texture unit
 > if it's bound to a unit. The spec calls for default object when 
deleting
 > sampler objects which are currently bound.

Candidate for the stable branches, I think.


 >
 > Signed-off-by: Alan Hourihane <alanh at vmware.com>
 > ---
 >  src/mesa/main/samplerobj.c |   10 ++++++++++
 >  1 files changed, 10 insertions(+), 0 deletions(-)
 >
 > diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
 > index 319a444..2279055 100644
 > --- a/src/mesa/main/samplerobj.c
 > +++ b/src/mesa/main/samplerobj.c
 > @@ -206,9 +206,19 @@ _mesa_DeleteSamplers(GLsizei count, const 
GLuint *samplers)
 >
 >     for (i = 0; i < count; i++) {
 >        if (samplers[i]) {
 > +         GLsizei j;

GLuint j (so that we don't get signed/unsigned comparison warnings 
from the loop below).


 >           struct gl_sampler_object *sampObj =
 >              _mesa_lookup_samplerobj(ctx, samplers[i]);
 > +
 >           if (sampObj) {
 > +            /* If the sampler is currently bound, unbind it. */
 > +            for (j = 0; j < 
ctx->Const.MaxCombinedTextureImageUnits; j++) {
 > +               if (ctx->Texture.Unit[j].Sampler == sampObj) {
 > +                  FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 > +                  _mesa_reference_sampler_object(ctx, 
&ctx->Texture.Unit[j].Sam
 > pler, NULL);
 > +               }
 > +            }
 > +
 >              /* The ID is immediately freed for re-use */
 >              _mesa_HashRemove(ctx->Shared->SamplerObjects, 
samplers[i]);
 >              /* But the object exists until its reference count 
goes to zero */

Reviewed-by: Brian Paul <brianp at vmware.com>

Thanks, Alan.

-Brian


More information about the mesa-dev mailing list