From f7c1a2dacd1643a19fbf975c21ac3e64b708c8d7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Jan 2009 11:23:12 -0700 Subject: mesa: initial bits for GL_EXT_vertex_array_bgra --- src/mesa/main/extensions.c | 1 + src/mesa/main/mtypes.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 188e01c8a4..bdc382bf9d 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -129,6 +129,7 @@ static const struct { { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) }, { OFF, "GL_EXT_timer_query", F(EXT_timer_query) }, { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) }, + { OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) }, { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) }, { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) }, { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) }, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f1da638ae6..5c31f66ed1 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1661,6 +1661,7 @@ struct gl_client_array { GLint Size; /**< components per element (1,2,3,4) */ GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */ + GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */ GLsizei Stride; /**< user-specified stride */ GLsizei StrideB; /**< actual stride in bytes */ const GLubyte *Ptr; /**< Points to array data */ @@ -2611,6 +2612,7 @@ struct gl_extensions GLboolean EXT_texture_sRGB; GLboolean EXT_timer_query; GLboolean EXT_vertex_array; + GLboolean EXT_vertex_array_bgra; GLboolean EXT_vertex_array_set; /* vendor extensions */ GLboolean APPLE_client_storage; -- cgit v1.2.3 From 76d27a6a1e94e973e5a0a4a22b80158dfecf9151 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Jan 2009 11:24:31 -0700 Subject: mesa: update glColorPointer, etc for GL_EXT_vertex_array_bgra Add new error checking, set array state appropriately. --- src/mesa/main/varray.c | 86 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 9d9b28b518..106252e460 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -52,11 +52,13 @@ static void update_array(GLcontext *ctx, struct gl_client_array *array, GLbitfield dirtyBit, GLsizei elementSize, - GLint size, GLenum type, + GLint size, GLenum type, GLenum format, GLsizei stride, GLboolean normalized, const GLvoid *ptr) { + ASSERT(format == GL_RGBA || format == GL_BGRA); array->Size = size; array->Type = type; + array->Format = format; array->Stride = stride; array->StrideB = stride ? stride : elementSize; array->Normalized = normalized; @@ -132,7 +134,7 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) } update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX, - elementSize, size, type, stride, GL_FALSE, ptr); + elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr); if (ctx->Driver.VertexPointer) ctx->Driver.VertexPointer( ctx, size, type, stride, ptr ); @@ -182,7 +184,7 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) } update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL, - elementSize, 3, type, stride, GL_TRUE, ptr); + elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr); if (ctx->Driver.NormalPointer) ctx->Driver.NormalPointer( ctx, type, stride, ptr ); @@ -193,12 +195,15 @@ void GLAPIENTRY _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { GLsizei elementSize; + GLenum format; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (size < 3 || size > 4) { - _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" ); - return; + if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { + _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(size)"); + return; + } } if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" ); @@ -209,6 +214,18 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size, _mesa_lookup_enum_by_nr( type ), stride); + if (size == GL_BGRA) { + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(GL_BGRA/GLubyte)"); + return; + } + format = GL_BGRA; + size = 4; + } + else { + format = GL_RGBA; + } + switch (type) { case GL_BYTE: elementSize = size * sizeof(GLbyte); @@ -245,7 +262,7 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) } update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0, - elementSize, size, type, stride, GL_TRUE, ptr); + elementSize, size, type, format, stride, GL_TRUE, ptr); if (ctx->Driver.ColorPointer) ctx->Driver.ColorPointer( ctx, size, type, stride, ptr ); @@ -277,7 +294,7 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) } update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD, - elementSize, 1, type, stride, GL_FALSE, ptr); + elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); if (ctx->Driver.FogCoordPointer) ctx->Driver.FogCoordPointer( ctx, type, stride, ptr ); @@ -318,7 +335,7 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) } update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX, - elementSize, 1, type, stride, GL_FALSE, ptr); + elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); if (ctx->Driver.IndexPointer) ctx->Driver.IndexPointer( ctx, type, stride, ptr ); @@ -330,12 +347,15 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { GLsizei elementSize; + GLenum format; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (size != 3 && size != 4) { - _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)" ); - return; + if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { + _mesa_error(ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)"); + return; + } } if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" ); @@ -346,6 +366,18 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n", size, _mesa_lookup_enum_by_nr( type ), stride); + if (size == GL_BGRA) { + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(GL_BGRA/GLubyte)"); + return; + } + format = GL_BGRA; + size = 4; + } + else { + format = GL_RGBA; + } + switch (type) { case GL_BYTE: elementSize = size * sizeof(GLbyte); @@ -377,7 +409,7 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, } update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1, - elementSize, size, type, stride, GL_TRUE, ptr); + elementSize, size, type, format, stride, GL_TRUE, ptr); if (ctx->Driver.SecondaryColorPointer) ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr ); @@ -437,7 +469,7 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit], _NEW_ARRAY_TEXCOORD(unit), - elementSize, size, type, stride, GL_FALSE, ptr); + elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr); if (ctx->Driver.TexCoordPointer) ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr ); @@ -456,7 +488,8 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) } update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG, - sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, ptr); + sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA, + stride, GL_FALSE, ptr); if (ctx->Driver.EdgeFlagPointer) ctx->Driver.EdgeFlagPointer( ctx, stride, ptr ); @@ -490,7 +523,7 @@ _mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr) } update_array(ctx, &ctx->Array.ArrayObj->PointSize, _NEW_ARRAY_POINT_SIZE, - elementSize, 1, type, stride, GL_FALSE, ptr); + elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); } @@ -546,7 +579,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], _NEW_ARRAY_ATTRIB(index), - elementSize, size, type, stride, normalized, ptr); + elementSize, size, type, GL_RGBA, stride, normalized, ptr); if (ctx->Driver.VertexAttribPointer) ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr ); @@ -561,6 +594,7 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { GLsizei elementSize; + GLenum format; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -570,8 +604,10 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, } if (size < 1 || size > 4) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)"); - return; + if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { + _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)"); + return; + } } if (stride < 0) { @@ -579,6 +615,20 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, return; } + if (size == GL_BGRA) { + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glVertexAttribPointerARB(GL_BGRA/type)"); + return; + } + format = GL_BGRA; + size = 4; + normalized = GL_TRUE; + } + else { + format = GL_RGBA; + } + /* check for valid 'type' and compute StrideB right away */ /* NOTE: more types are supported here than in the NV extension */ switch (type) { @@ -618,7 +668,7 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], _NEW_ARRAY_ATTRIB(index), - elementSize, size, type, stride, normalized, ptr); + elementSize, size, type, GL_RGBA, stride, normalized, ptr); if (ctx->Driver.VertexAttribPointer) ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr); -- cgit v1.2.3 From 9cf594d698839678290f058078f0eaf569a13ff8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Jan 2009 11:25:13 -0700 Subject: mesa: improve array initialization code, and set the new array->Format field. --- src/mesa/main/arrayobj.c | 108 +++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 75 deletions(-) (limited to 'src') diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index f3f482f8c8..b04095fd16 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -98,6 +98,28 @@ _mesa_delete_array_object( GLcontext *ctx, struct gl_array_object *obj ) } +static void +init_array(GLcontext *ctx, + struct gl_client_array *array, GLint size, GLint type) +{ + array->Size = size; + array->Type = type; + array->Format = GL_RGBA; /* only significant for GL_EXT_vertex_array_bgra */ + array->Stride = 0; + array->StrideB = 0; + array->Ptr = NULL; + array->Enabled = GL_FALSE; + array->Normalized = GL_FALSE; +#if FEATURE_ARB_vertex_buffer_object + /* Vertex array buffers */ + array->BufferObj = ctx->Array.NullBufferObj; +#endif +} + + +/** + * Initialize a gl_array_object's arrays. + */ void _mesa_initialize_array_object( GLcontext *ctx, struct gl_array_object *obj, @@ -107,87 +129,23 @@ _mesa_initialize_array_object( GLcontext *ctx, obj->Name = name; - /* Vertex arrays */ - obj->Vertex.Size = 4; - obj->Vertex.Type = GL_FLOAT; - obj->Vertex.Stride = 0; - obj->Vertex.StrideB = 0; - obj->Vertex.Ptr = NULL; - obj->Vertex.Enabled = GL_FALSE; - obj->Normal.Type = GL_FLOAT; - obj->Normal.Stride = 0; - obj->Normal.StrideB = 0; - obj->Normal.Ptr = NULL; - obj->Normal.Enabled = GL_FALSE; - obj->Color.Size = 4; - obj->Color.Type = GL_FLOAT; - obj->Color.Stride = 0; - obj->Color.StrideB = 0; - obj->Color.Ptr = NULL; - obj->Color.Enabled = GL_FALSE; - obj->SecondaryColor.Size = 4; - obj->SecondaryColor.Type = GL_FLOAT; - obj->SecondaryColor.Stride = 0; - obj->SecondaryColor.StrideB = 0; - obj->SecondaryColor.Ptr = NULL; - obj->SecondaryColor.Enabled = GL_FALSE; - obj->FogCoord.Size = 1; - obj->FogCoord.Type = GL_FLOAT; - obj->FogCoord.Stride = 0; - obj->FogCoord.StrideB = 0; - obj->FogCoord.Ptr = NULL; - obj->FogCoord.Enabled = GL_FALSE; - obj->Index.Type = GL_FLOAT; - obj->Index.Stride = 0; - obj->Index.StrideB = 0; - obj->Index.Ptr = NULL; - obj->Index.Enabled = GL_FALSE; + /* Init the individual arrays */ + init_array(ctx, &obj->Vertex, 4, GL_FLOAT); + init_array(ctx, &obj->Normal, 3, GL_FLOAT); + init_array(ctx, &obj->Color, 4, GL_FLOAT); + init_array(ctx, &obj->SecondaryColor, 4, GL_FLOAT); + init_array(ctx, &obj->FogCoord, 1, GL_FLOAT); + init_array(ctx, &obj->Index, 1, GL_FLOAT); for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { - obj->TexCoord[i].Size = 4; - obj->TexCoord[i].Type = GL_FLOAT; - obj->TexCoord[i].Stride = 0; - obj->TexCoord[i].StrideB = 0; - obj->TexCoord[i].Ptr = NULL; - obj->TexCoord[i].Enabled = GL_FALSE; + init_array(ctx, &obj->TexCoord[i], 4, GL_FLOAT); } - obj->EdgeFlag.Stride = 0; - obj->EdgeFlag.StrideB = 0; - obj->EdgeFlag.Ptr = NULL; - obj->EdgeFlag.Enabled = GL_FALSE; + init_array(ctx, &obj->EdgeFlag, 1, GL_BOOL); for (i = 0; i < VERT_ATTRIB_MAX; i++) { - obj->VertexAttrib[i].Size = 4; - obj->VertexAttrib[i].Type = GL_FLOAT; - obj->VertexAttrib[i].Stride = 0; - obj->VertexAttrib[i].StrideB = 0; - obj->VertexAttrib[i].Ptr = NULL; - obj->VertexAttrib[i].Enabled = GL_FALSE; - obj->VertexAttrib[i].Normalized = GL_FALSE; + init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT); } #if FEATURE_point_size_array - obj->PointSize.Type = GL_FLOAT; - obj->PointSize.Stride = 0; - obj->PointSize.StrideB = 0; - obj->PointSize.Ptr = NULL; - obj->PointSize.Enabled = GL_FALSE; - obj->PointSize.BufferObj = ctx->Array.NullBufferObj; -#endif - -#if FEATURE_ARB_vertex_buffer_object - /* Vertex array buffers */ - obj->Vertex.BufferObj = ctx->Array.NullBufferObj; - obj->Normal.BufferObj = ctx->Array.NullBufferObj; - obj->Color.BufferObj = ctx->Array.NullBufferObj; - obj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj; - obj->FogCoord.BufferObj = ctx->Array.NullBufferObj; - obj->Index.BufferObj = ctx->Array.NullBufferObj; - for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { - obj->TexCoord[i].BufferObj = ctx->Array.NullBufferObj; - } - obj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj; - for (i = 0; i < VERT_ATTRIB_MAX; i++) { - obj->VertexAttrib[i].BufferObj = ctx->Array.NullBufferObj; - } + init_array(ctx, &obj->PointSize, 1, GL_FLOAT); #endif } -- cgit v1.2.3 From 0791fdff6fe87cf9a29ddf4a716f1881c367c7de Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Jan 2009 11:26:30 -0700 Subject: mesa: update tnl module for GL_EXT_vertex_array_bgra Add special case for GLubyte/GL_BGRA color arrays in _tnl_import_array() --- src/mesa/tnl/t_draw.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index fd647c1f4a..2ec65d5323 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -88,6 +88,29 @@ static void free_space(GLcontext *ctx) } while (0) +/** + * Convert array of BGRA/GLubyte[4] values to RGBA/float[4] + * \param ptr input/ubyte array + * \param fptr output/float array + */ +static void +convert_bgra_to_float(const struct gl_client_array *input, + const GLubyte *ptr, GLfloat *fptr, + GLuint count ) +{ + GLuint i; + assert(input->Normalized); + assert(input->Size == 4); + for (i = 0; i < count; i++) { + const GLubyte *in = (GLubyte *) ptr; /* in is in BGRA order */ + *fptr++ = UBYTE_TO_FLOAT(in[2]); /* red */ + *fptr++ = UBYTE_TO_FLOAT(in[1]); /* green */ + *fptr++ = UBYTE_TO_FLOAT(in[0]); /* blue */ + *fptr++ = UBYTE_TO_FLOAT(in[3]); /* alpha */ + ptr += input->StrideB; + } +} + /* Adjust pointer to point at first requested element, convert to * floating point, populate VB->AttribPtr[]. @@ -112,7 +135,13 @@ static void _tnl_import_array( GLcontext *ctx, CONVERT(GLbyte, BYTE_TO_FLOAT); break; case GL_UNSIGNED_BYTE: - CONVERT(GLubyte, UBYTE_TO_FLOAT); + if (input->Format == GL_BGRA) { + /* See GL_EXT_vertex_array_bgra */ + convert_bgra_to_float(input, ptr, fptr, count); + } + else { + CONVERT(GLubyte, UBYTE_TO_FLOAT); + } break; case GL_SHORT: CONVERT(GLshort, SHORT_TO_FLOAT); -- cgit v1.2.3 From 0bd6d48bcea7de37e027854e9d91c54116fbe90e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Jan 2009 11:26:51 -0700 Subject: mesa: enable GL_EXT_vertex_array_bgra for sw drivers --- src/mesa/main/extensions.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index bdc382bf9d..8010823cf5 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -272,6 +272,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) #if FEATURE_EXT_texture_sRGB ctx->Extensions.EXT_texture_sRGB = GL_TRUE; #endif + ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE; ctx->Extensions.MESA_pack_invert = GL_TRUE; #if FEATURE_MESA_program_debug -- cgit v1.2.3 From dab586b0755bffa7c4da0fdc571e0f504f4066c2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Jan 2009 11:27:42 -0700 Subject: i965: enable GL_EXT_vertex_array_bgra Simply a matter of choosing the right surface/vertex format for GLubyte/GL_BGRA arrays. --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 20 ++++++++++++++++++-- src/mesa/drivers/dri/intel/intel_context.c | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 73d6dea01e..f89c0c2ba4 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -156,7 +156,13 @@ static GLuint byte_types_scale[5] = { }; -static GLuint get_surface_type( GLenum type, GLuint size, GLboolean normalized ) +/** + * Given vertex array type/size/format/normalized info, return + * the appopriate hardware surface type. + * Format will be GL_RGBA or possibly GL_BGRA for GLubyte[4] color arrays. + */ +static GLuint get_surface_type( GLenum type, GLuint size, + GLenum format, GLboolean normalized ) { if (INTEL_DEBUG & DEBUG_VERTS) _mesa_printf("type %s size %d normalized %d\n", @@ -171,11 +177,20 @@ static GLuint get_surface_type( GLenum type, GLuint size, GLboolean normalized ) case GL_BYTE: return byte_types_norm[size]; case GL_UNSIGNED_INT: return uint_types_norm[size]; case GL_UNSIGNED_SHORT: return ushort_types_norm[size]; - case GL_UNSIGNED_BYTE: return ubyte_types_norm[size]; + case GL_UNSIGNED_BYTE: + if (format == GL_BGRA) { + /* See GL_EXT_vertex_array_bgra */ + assert(size == 4); + return BRW_SURFACEFORMAT_B8G8R8A8_UNORM; + } + else { + return ubyte_types_norm[size]; + } default: assert(0); return 0; } } else { + assert(format == GL_RGBA); /* sanity check */ switch (type) { case GL_DOUBLE: return double_types[size]; case GL_FLOAT: return float_types[size]; @@ -484,6 +499,7 @@ static void brw_emit_vertices(struct brw_context *brw) struct brw_vertex_element *input = enabled[i]; uint32_t format = get_surface_type(input->glarray->Type, input->glarray->Size, + input->glarray->Format, input->glarray->Normalized); uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC; uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC; diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index fda880829c..a43e6be0d9 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -414,6 +414,7 @@ static const struct dri_extension brw_extensions[] = { { "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions }, { "GL_EXT_shadow_funcs", NULL }, { "GL_EXT_texture_sRGB", NULL }, + { "GL_EXT_vertex_array_bgra", NULL }, { "GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions }, { "GL_ATI_texture_env_combine3", NULL }, { NULL, NULL } -- cgit v1.2.3