meta: Track VBO using gl_buffer_object instead of GL API object handle in _mesa_meta_...
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 5 Nov 2015 22:31:23 +0000 (14:31 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 24 Nov 2015 19:31:30 +0000 (11:31 -0800)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/drivers/common/meta.c
src/mesa/drivers/common/meta.h

index 328e06069d45e57488d29db91f6ca194e293b4b9..b38ac902264fd80a101350a1c02d8c5f33e93663 100644 (file)
@@ -3310,20 +3310,32 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
    if (drawtex->VAO == 0) {
       /* one-time setup */
       GLint active_texture;
+      GLuint VBO;
 
       /* create vertex array object */
       _mesa_GenVertexArrays(1, &drawtex->VAO);
       _mesa_BindVertexArray(drawtex->VAO);
 
       /* create vertex array buffer */
-      _mesa_CreateBuffers(1, &drawtex->VBO);
-      _mesa_NamedBufferData(drawtex->VBO, sizeof(verts),
-                            NULL, GL_DYNAMIC_DRAW_ARB);
+      _mesa_CreateBuffers(1, &VBO);
+      drawtex->buf_obj = _mesa_lookup_bufferobj(ctx, VBO);
+
+      /* _mesa_lookup_bufferobj only returns NULL if name is 0.  If the object
+       * does not yet exist (i.e., hasn't been bound) it will return a dummy
+       * object that you can't do anything with.
+       */
+      assert(drawtex->buf_obj != NULL && (drawtex->buf_obj)->Name == VBO);
+      assert(drawtex->buf_obj == ctx->Array.ArrayBufferObj);
+
+      _mesa_buffer_data(ctx, drawtex->buf_obj, GL_NONE, sizeof(verts), verts,
+                        GL_DYNAMIC_DRAW, __func__);
+
+      assert(drawtex->buf_obj->Size == sizeof(verts));
 
       /* client active texture is not part of the array object */
       active_texture = ctx->Array.ActiveTexture;
 
-      _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, drawtex->VBO);
+      _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, VBO);
 
       /* setup vertex arrays */
       _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
@@ -3403,7 +3415,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
          verts[3].st[i][1] = t1;
       }
 
-      _mesa_NamedBufferSubData(drawtex->VBO, 0, sizeof(verts), verts);
+      _mesa_buffer_sub_data(ctx, drawtex->buf_obj, 0, sizeof(verts), verts,
+                            __func__);
    }
 
    _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
index 6df76ae6f3d9b702a43845bdcda6dcd6c115a50e..e55fd86f0928c75ba72c76b868c8a76f0e966789 100644 (file)
@@ -408,7 +408,7 @@ struct decompress_state
 struct drawtex_state
 {
    GLuint VAO;
-   GLuint VBO;
+   struct gl_buffer_object *buf_obj;
 };
 
 #define MAX_META_OPS_DEPTH      8