[Mesa-dev] [PATCH] mesa: attach ElementArrayBufferObj to vertex array object

Yuanhan Liu yuanhan.liu at linux.intel.com
Tue Nov 22 00:38:20 PST 2011


This would make ElementArrayBufferObj data per vertex array object. I did't
find something to support this at the spec page[0]. But I did find
something that somehow support this at opengl wiki page[1].

NOTE: with my test, both NV and ATI's closed source opengl
implementation would attach the Elelemnt array buffer to vao.

This would fix most of(3 left) intel oglc vao test fail

[0]: http://www.opengl.org/registry/specs/ARB/vertex_array_object.txt
[1]: http://www.opengl.org/wiki/Vertex_Array_Object

Cc: idr at freedesktop.org
Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
 src/mesa/main/arrayobj.c  |    2 ++
 src/mesa/main/bufferobj.c |    4 ++++
 src/mesa/main/mtypes.h    |    2 ++
 3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 1283940..765a7d5 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -382,6 +382,8 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired)
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= _NEW_ARRAY_ALL;
    _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, newObj);
+   if (newObj->ElementArrayBufferObj)
+      _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, newObj->ElementArrayBufferObj);
 
    /* Pass BindVertexArray call to device driver */
    if (ctx->Driver.BindArrayObject && newObj)
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 4c77397..d96dc5f 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -603,6 +603,10 @@ bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer)
    /* bind new buffer */
    _mesa_reference_buffer_object(ctx, bindTarget, newBufObj);
 
+   if (target == GL_ELEMENT_ARRAY_BUFFER) {
+      _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayObj->ElementArrayBufferObj, newBufObj);
+   }
+
    /* Pass BindBuffer call to device driver */
    if (ctx->Driver.BindBuffer)
       ctx->Driver.BindBuffer( ctx, target, newBufObj );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b3427da..5cd1084 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1620,6 +1620,8 @@ struct gl_array_object
     * we can determine the max legal (in bounds) glDrawElements array index.
     */
    GLuint _MaxElement;
+
+   struct gl_buffer_object *ElementArrayBufferObj;
 };
 
 
-- 
1.7.4.4



More information about the mesa-dev mailing list