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

Anuj Phogat anuj.phogat at gmail.com
Wed Mar 12 18:13:32 PDT 2014


On Wed, Mar 12, 2014 at 5:50 PM, Brian Paul <brianp at vmware.com> wrote:

> On 03/12/2014 05:41 PM, Anuj Phogat wrote:
>
>> 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);
>>
>
> Instead of adding a new field, can't this be done as:
>
> return (array->Format == GL_BGRA) ? GL_BGRA : array->Size;
>
Yes, that's what I should have done. Will send out V2.


>
> -Brian
>
>
>
>       case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
>>         return array->Stride;
>>      case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
>>
>>
> _______________________________________________
> mesa-stable mailing list
> mesa-stable at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-stable
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-stable/attachments/20140312/76ae3fc6/attachment.html>


More information about the mesa-stable mailing list