summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@vmware.com>2013-03-06 16:08:58 +0000
committerAndreas Boll <andreas.boll.dev@gmail.com>2013-04-17 12:53:27 +0200
commitb2316b488e901c9c0ed473915f4338d82790f80f (patch)
tree382a2afb3ffa17329e9a5b9cf5a97962f3cf713f
parent3184fef2956a6916331e7300670f8cb05572e77b (diff)
Unreference sampler object when it's currently bound to texture unit.
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. Note: this is a candidate for the stable branches Signed-off-by: Alan Hourihane <alanh@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com> (cherry picked from commit cf0b4a30fc536f3744bce209d4b356fe82f2e6a3)
-rw-r--r--src/mesa/main/samplerobj.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 8bf5f490a1..c746e42bb0 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -209,9 +209,19 @@ _mesa_DeleteSamplers(GLsizei count, const GLuint *samplers)
for (i = 0; i < count; i++) {
if (samplers[i]) {
+ GLuint j;
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].Sampler, 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 */