[Mesa-stable] [PATCH] mesa: Fix glGetVertexAttribi(GL_VERTEX_ATTRIB_ARRAY_SIZE)

Anuj Phogat anuj.phogat at gmail.com
Wed Mar 12 16:41:11 PDT 2014


mesa currently returns 4 when GL_VERTEX_ATTRIB_ARRAY_SIZE is queried
for a vertex array initially set up with size=GL_BGRA. This patch
makes changes to return size=GL_BGRA as required by the spec.

Fixes Khronos OpenGL CTS test: vertex_array_bgra_basic.test

Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
Cc: <mesa-stable at lists.freedesktop.org>
---
 src/mesa/main/arrayobj.c | 1 +
 src/mesa/main/mtypes.h   | 1 +
 src/mesa/main/varray.c   | 5 ++++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index efb9930..2b234f3 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -200,6 +200,7 @@ init_array(struct gl_context *ctx,
    array->Enabled = GL_FALSE;
    array->Normalized = GL_FALSE;
    array->Integer = GL_FALSE;
+   array->SizeBGRA = GL_FALSE;
    array->_ElementSize = size * _mesa_sizeof_type(type);
    array->VertexBinding = index;
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 2bad4ca..52874a7 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1545,6 +1545,7 @@ struct gl_vertex_attrib_array
    GLboolean Enabled;       /**< Whether the array is enabled */
    GLboolean Normalized;    /**< Fixed-point values are normalized when converted to floats */
    GLboolean Integer;       /**< Fixed-point values are not converted to floats */
+   GLboolean SizeBGRA;      /**< True if Size is GL_BGRA */
    GLuint _ElementSize;     /**< Size of each element in bytes */
    GLuint VertexBinding;    /**< Vertex buffer binding */
 };
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index b4b6fa9..3bc361e 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -207,6 +207,7 @@ update_array_format(struct gl_context *ctx,
    GLbitfield typeBit;
    GLuint elementSize;
    GLenum format = GL_RGBA;
+   GLboolean size_bgra = GL_FALSE;
 
    if (_mesa_is_gles(ctx)) {
       legalTypesMask &= ~(FIXED_GL_BIT | DOUBLE_BIT | UNSIGNED_INT_10F_11F_11F_REV_BIT);
@@ -291,6 +292,7 @@ update_array_format(struct gl_context *ctx,
       }
 
       format = GL_BGRA;
+      size_bgra = GL_TRUE;
       size = 4;
    }
    else if (size < sizeMin || size > sizeMax || size > 4) {
@@ -335,6 +337,7 @@ update_array_format(struct gl_context *ctx,
    array->Format = format;
    array->Normalized = normalized;
    array->Integer = integer;
+   array->SizeBGRA = size_bgra;
    array->RelativeOffset = relativeOffset;
    array->_ElementSize = elementSize;
 
@@ -738,7 +741,7 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
    case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
       return array->Enabled;
    case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
-      return array->Size;
+      return (array->SizeBGRA ? GL_BGRA : array->Size);
    case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
       return array->Stride;
    case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
-- 
1.8.3.1



More information about the mesa-stable mailing list