mesa: don't re-use the meta glDrawPixels VBO; create a new one each time
authorBrian Paul <brianp@vmware.com>
Tue, 22 Sep 2009 21:58:12 +0000 (15:58 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 22 Sep 2009 21:58:49 +0000 (15:58 -0600)
This should help to work around bugs 24083 and 23670.

src/mesa/drivers/common/meta.c

index ddd476eba1ca49e0bd1155da4cbba55e1a356d02..2741a41bf395e3e80538d2ed7fa006a41667f6d7 100644 (file)
@@ -174,7 +174,6 @@ struct copypix_state
 struct drawpix_state
 {
    GLuint ArrayObj;
-   GLuint VBO;
 
    GLuint StencilFP;  /**< Fragment program for drawing stencil images */
    GLuint DepthFP;  /**< Fragment program for drawing depth images */
@@ -262,7 +261,6 @@ _mesa_meta_free(GLcontext *ctx)
       _mesa_DeleteVertexArraysAPPLE(1, &meta->CopyPix.ArrayObj);
 
       /* glDrawPixels */
-      _mesa_DeleteBuffersARB(1, & meta->DrawPix.VBO);
       _mesa_DeleteVertexArraysAPPLE(1, &meta->DrawPix.ArrayObj);
       _mesa_DeletePrograms(1, &meta->DrawPix.DepthFP);
       _mesa_DeletePrograms(1, &meta->DrawPix.StencilFP);
@@ -1430,6 +1428,7 @@ _mesa_meta_draw_pixels(GLcontext *ctx,
    GLenum texIntFormat;
    GLboolean fallback, newTex;
    GLbitfield metaExtraSave = 0x0;
+   GLuint vbo;
 
    /*
     * Determine if we can do the glDrawPixels with texture mapping.
@@ -1509,32 +1508,6 @@ _mesa_meta_draw_pixels(GLcontext *ctx,
                           META_VIEWPORT |
                           metaExtraSave));
 
-   if (drawpix->ArrayObj == 0) {
-      /* one-time setup */
-
-      /* create vertex array object */
-      _mesa_GenVertexArrays(1, &drawpix->ArrayObj);
-      _mesa_BindVertexArray(drawpix->ArrayObj);
-
-      /* create vertex array buffer */
-      _mesa_GenBuffersARB(1, &drawpix->VBO);
-      _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, drawpix->VBO);
-      _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
-                          NULL, GL_DYNAMIC_DRAW_ARB);
-
-      /* setup vertex arrays */
-      _mesa_VertexPointer(3, GL_FLOAT, sizeof(verts[0]),
-                          (void *) (0 * sizeof(GLfloat)));
-      _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(verts[0]),
-                            (void *) (3 * sizeof(GLfloat)));
-      _mesa_EnableClientState(GL_VERTEX_ARRAY);
-      _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
-   }
-   else {
-      _mesa_BindVertexArray(drawpix->ArrayObj);
-      _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, drawpix->VBO);
-   }
-
    newTex = alloc_texture(tex, width, height, texIntFormat);
 
    /* vertex positions, texcoords (after texture allocation!) */
@@ -1565,10 +1538,27 @@ _mesa_meta_draw_pixels(GLcontext *ctx,
       verts[3][2] = z;
       verts[3][3] = 0.0F;
       verts[3][4] = tex->Ttop;
+   }
 
-      /* upload new vertex data */
-      _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
+   if (drawpix->ArrayObj == 0) {
+      /* one-time setup: create vertex array object */
+      _mesa_GenVertexArrays(1, &drawpix->ArrayObj);
    }
+   _mesa_BindVertexArray(drawpix->ArrayObj);
+
+   /* create vertex array buffer */
+   _mesa_GenBuffersARB(1, &vbo);
+   _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
+   _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts),
+                       verts, GL_DYNAMIC_DRAW_ARB);
+
+   /* setup vertex arrays */
+   _mesa_VertexPointer(3, GL_FLOAT, sizeof(verts[0]),
+                       (void *) (0 * sizeof(GLfloat)));
+   _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(verts[0]),
+                         (void *) (3 * sizeof(GLfloat)));
+   _mesa_EnableClientState(GL_VERTEX_ARRAY);
+   _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
 
    /* set given unpack params */
    ctx->Unpack = *unpack;
@@ -1639,6 +1629,8 @@ _mesa_meta_draw_pixels(GLcontext *ctx,
 
    _mesa_Disable(tex->Target);
 
+   _mesa_DeleteBuffersARB(1, &vbo);
+
    /* restore unpack params */
    ctx->Unpack = unpackSave;