X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fvarray.c;h=106252e46098c12455b014da6a43661e928ef564;hb=b6e8256899a9a93c665c34e10efcc918f2fcc095;hp=f41ee73c884e3ea666992ea604894010e1d60828;hpb=3e0797f3b702a1363bf238eb4826385860346137;p=mesa.git diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index f41ee73c884..106252e4609 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.2 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -52,24 +52,21 @@ 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; array->Ptr = (const GLubyte *) ptr; #if FEATURE_ARB_vertex_buffer_object - array->BufferObj->RefCount--; - if (array->BufferObj->RefCount <= 0) { - ASSERT(array->BufferObj->Name); - _mesa_remove_buffer_object( ctx, array->BufferObj ); - (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj ); - } - array->BufferObj = ctx->Array.ArrayBufferObj; - array->BufferObj->RefCount++; + _mesa_reference_buffer_object(ctx, &array->BufferObj, + ctx->Array.ArrayBufferObj); + /* Compute the index of the last array element that's inside the buffer. * Later in glDrawArrays we'll check if start + count > _MaxElement to * be sure we won't go out of bounds. @@ -121,13 +118,23 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; +#if FEATURE_fixedpt + case GL_FIXED: + elementSize = size * sizeof(GLfixed); + break; +#endif +#if FEATURE_vertex_array_byte + case GL_BYTE: + elementSize = size * sizeof(GLbyte); + break; +#endif default: _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" ); return; } 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 ); @@ -166,13 +173,18 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) case GL_DOUBLE: elementSize = 3 * sizeof(GLdouble); break; +#if FEATURE_fixedpt + case GL_FIXED: + elementSize = 3 * sizeof(GLfixed); + break; +#endif default: _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" ); return; } 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 ); @@ -183,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)" ); @@ -199,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); @@ -224,13 +251,18 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; +#if FEATURE_fixedpt + case GL_FIXED: + elementSize = size * sizeof(GLfixed); + break; +#endif default: _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" ); return; } 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 ); @@ -262,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 ); @@ -303,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 ); @@ -315,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)" ); @@ -331,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); @@ -362,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 ); @@ -405,6 +452,16 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; +#if FEATURE_fixedpt + case GL_FIXED: + elementSize = size * sizeof(GLfixed); + break; +#endif +#if FEATURE_vertex_array_byte + case GL_BYTE: + elementSize = size * sizeof(GLbyte); + break; +#endif default: _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" ); return; @@ -412,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 ); @@ -431,13 +488,45 @@ _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 ); } +void GLAPIENTRY +_mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr) +{ + GLsizei elementSize; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (stride < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPointSizePointer(stride)" ); + return; + } + + switch (type) { + case GL_FLOAT: + elementSize = sizeof(GLfloat); + break; +#if FEATURE_fixedpt + case GL_FIXED: + elementSize = sizeof(GLfixed); + break; +#endif + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glPointSizePointer(type)" ); + return; + } + + update_array(ctx, &ctx->Array.ArrayObj->PointSize, _NEW_ARRAY_POINT_SIZE, + elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); +} + + #if FEATURE_NV_vertex_program void GLAPIENTRY _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, @@ -490,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 ); @@ -505,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); @@ -514,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) { @@ -523,9 +615,18 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, return; } - if (type == GL_UNSIGNED_BYTE && size != 4) { - _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size!=4)"); - 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 */ @@ -555,6 +656,11 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; +#if FEATURE_fixedpt + case GL_FIXED: + elementSize = size * sizeof(GLfixed); + break; +#endif default: _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" ); return; @@ -562,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);