_mesa_BindTexture performs no operation if the texture being bound is the same as the texture that is already bound. There is a comment in the code that suggests that this optimization may not be correct in certain multicontext cases. After some discussions at the ARB meeting, I believe that this optimization is wrong for 3 reasons. 1. The synchronization issue mentioned in the code. 2. glBindTexture is defined as unbinding the currently bound texture, then binding the named texture. In the multicontext case, given contexts A and B, it is possible for context A to delete the texture while it is bound in context B. If B binds the texture while it is bound, the implicit unbind would cause the texture to be destroyed. By short circuiting that step, the behavior is changed. 3. While the multicontext cases are a bit esoteric, the case where a texture is bound as a texture and attached to a framebuffer object is not. The same synchronization issue mentioned in the code WRT the multicontext case exists in the case of a single context with a framebuffer object. Even if this optimization were removed, the code would not be correct. In effect, the existing code binds the new texture, then unbinds the old texture. I believe the correct fix is to replace the short circuit with code from the end of the function that decrements the refernce count on the texture object and, if the count is zero, deletes the object.
Mass version move, cvs -> git
The optimisation no longer appears to be there. Likely this was fixed a while ago considering how old this bug is. Either way it doesn't seem to be something people are running into. Closing.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.