Move all the code for computing ctx->_TriangleCaps into state.c.
[mesa.git] / src / mesa / main / fbobject.c
index b6a59336cb8103ef349905d2205e8a42e710e7a9..cf8de1e0cbe5bdb6de58b48fa203ee5c6117d20d 100644 (file)
@@ -33,6 +33,7 @@
 #include "fbobject.h"
 #include "framebuffer.h"
 #include "hash.h"
+#include "mipmap.h"
 #include "renderbuffer.h"
 #include "state.h"
 #include "teximage.h"
@@ -570,6 +571,12 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
    }
 
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+   /* The above doesn't fully flush the drivers in the way that a
+    * glFlush does, but that is required here:
+    */
+   if (ctx->Driver.Flush)
+      ctx->Driver.Flush(ctx);
+
 
    if (renderbuffer) {
       newRb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
@@ -972,7 +979,9 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
    }
 
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
-
+   if (ctx->Driver.Flush) {  
+      ctx->Driver.Flush(ctx);
+   }
    if (framebuffer) {
       /* Binding a user-created framebuffer object */
       newFb = _mesa_lookup_framebuffer(ctx, framebuffer);
@@ -1047,6 +1056,11 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
 
    ASSERT_OUTSIDE_BEGIN_END(ctx);
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+   /* The above doesn't fully flush the drivers in the way that a
+    * glFlush does, but that is required here:
+    */
+   if (ctx->Driver.Flush)
+      ctx->Driver.Flush(ctx);
 
    for (i = 0; i < n; i++) {
       if (framebuffers[i] > 0) {
@@ -1262,6 +1276,11 @@ framebuffer_texture(GLuint dims, GLenum target, GLenum attachment,
    }
 
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+   /* The above doesn't fully flush the drivers in the way that a
+    * glFlush does, but that is required here:
+    */
+   if (ctx->Driver.Flush)
+      ctx->Driver.Flush(ctx);
 
    _glthread_LOCK_MUTEX(fb->Mutex);
    if (texObj) {
@@ -1380,6 +1399,11 @@ _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
    }
 
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+   /* The above doesn't fully flush the drivers in the way that a
+    * glFlush does, but that is required here:
+    */
+   if (ctx->Driver.Flush)
+      ctx->Driver.Flush(ctx);
 
    assert(ctx->Driver.FramebufferRenderbuffer);
    ctx->Driver.FramebufferRenderbuffer(ctx, fb, attachment, rb);
@@ -1443,6 +1467,11 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
    }
 
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+   /* The above doesn't fully flush the drivers in the way that a
+    * glFlush does, but that is required here:
+    */
+   if (ctx->Driver.Flush)
+      ctx->Driver.Flush(ctx);
 
    switch (pname) {
    case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
@@ -1521,7 +1550,9 @@ _mesa_GenerateMipmapEXT(GLenum target)
    texObj = _mesa_select_tex_object(ctx, texUnit, target);
 
    /* XXX this might not handle cube maps correctly */
+   _mesa_lock_texture(ctx, texObj);
    _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+   _mesa_unlock_texture(ctx, texObj);
 }