Created attachment 99627 [details]
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0) should unbind both the depth and the stencil attachment. However, when using mesa 10.1 with Intel Haswell graphics, the stencil buffer is not unbound.
_mesa_framebuffer_renderbuffer has a special path to bind a stencil buffer when using GL_DEPTH_STENCIL_ATTACHMENT for a non-null renderbuffer, but for a null renderbuffer, it only calls remove_attachment with the depth attachment returned by get_attachment. It also needs to handle the stencil buffer when GL_DEPTH_STENCIL_ATTACHMENT is used for null renderbuffers.
I have attached a test case to demonstrate the problem. An assertion fails on line 61 when the bug occurs.
Created attachment 99628 [details]
This patch made against the mesa-10.1.4 tag fixes the bug for me.
The patch looks good, but I think I'll improve the comments.
I'll commit/push this and tag it for the stable branches too.