[Mesa-dev] [PATCH 16/35] meta: Track the _mesa_meta_DrawPixels VBO just like the others

Ian Romanick idr at freedesktop.org
Wed Jan 29 13:53:07 PST 2014


From: Ian Romanick <ian.d.romanick at intel.com>

All of the other meta routines have a particular pattern for creating
and tracking the VAO and VBO.  This one function deviated from that
pattern for no apparent reason.

Almost all of the code added in this patch will be removed shortly.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/drivers/common/meta.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index fb58b42..6718680 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -263,6 +263,7 @@ 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 */
@@ -2561,6 +2562,9 @@ meta_drawpix_cleanup(struct drawpix_state *drawpix)
    if (drawpix->ArrayObj != 0) {
       _mesa_DeleteVertexArrays(1, &drawpix->ArrayObj);
       drawpix->ArrayObj = 0;
+
+      _mesa_DeleteBuffers(1, &drawpix->VBO);
+      drawpix->VBO = 0;
    }
 
    if (drawpix->StencilFP != 0) {
@@ -2824,6 +2828,27 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
 
    newTex = alloc_texture(tex, width, height, texIntFormat);
 
+   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_GenBuffers(1, &drawpix->VBO);
+      _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, drawpix->VBO);
+      _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts),
+                       NULL, GL_DYNAMIC_DRAW_ARB);
+
+      /* setup vertex arrays */
+      _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
+      _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(tex));
+      _mesa_EnableClientState(GL_VERTEX_ARRAY);
+      _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
+   } else {
+      _mesa_BindVertexArray(drawpix->ArrayObj);
+      _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, drawpix->VBO);
+   }
+
    /* Silence valgrind warnings about reading uninitialized stack. */
    memset(verts, 0, sizeof(verts));
 
@@ -2857,24 +2882,10 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
       verts[3].tex[1] = tex->Ttop;
    }
 
-   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_GenBuffers(1, &vbo);
-   _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, vbo);
+   /* upload new vertex data */
    _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts),
                        verts, GL_DYNAMIC_DRAW_ARB);
 
-   /* setup vertex arrays */
-   _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
-   _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(tex));
-   _mesa_EnableClientState(GL_VERTEX_ARRAY);
-   _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
-
    /* set given unpack params */
    ctx->Unpack = *unpack;
 
-- 
1.8.1.4



More information about the mesa-dev mailing list