Merge branch 'vertex_array_bgra'
This commit is contained in:
@@ -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)
|
if (INTEL_DEBUG & DEBUG_VERTS)
|
||||||
_mesa_printf("type %s size %d normalized %d\n",
|
_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_BYTE: return byte_types_norm[size];
|
||||||
case GL_UNSIGNED_INT: return uint_types_norm[size];
|
case GL_UNSIGNED_INT: return uint_types_norm[size];
|
||||||
case GL_UNSIGNED_SHORT: return ushort_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;
|
default: assert(0); return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
assert(format == GL_RGBA); /* sanity check */
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GL_DOUBLE: return double_types[size];
|
case GL_DOUBLE: return double_types[size];
|
||||||
case GL_FLOAT: return float_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];
|
struct brw_vertex_element *input = enabled[i];
|
||||||
uint32_t format = get_surface_type(input->glarray->Type,
|
uint32_t format = get_surface_type(input->glarray->Type,
|
||||||
input->glarray->Size,
|
input->glarray->Size,
|
||||||
|
input->glarray->Format,
|
||||||
input->glarray->Normalized);
|
input->glarray->Normalized);
|
||||||
uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC;
|
uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC;
|
||||||
uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC;
|
uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC;
|
||||||
|
@@ -416,6 +416,7 @@ static const struct dri_extension brw_extensions[] = {
|
|||||||
{ "GL_EXT_shadow_funcs", NULL },
|
{ "GL_EXT_shadow_funcs", NULL },
|
||||||
{ "GL_EXT_stencil_two_side", GL_EXT_stencil_two_side_functions },
|
{ "GL_EXT_stencil_two_side", GL_EXT_stencil_two_side_functions },
|
||||||
{ "GL_EXT_texture_sRGB", NULL },
|
{ "GL_EXT_texture_sRGB", NULL },
|
||||||
|
{ "GL_EXT_vertex_array_bgra", NULL },
|
||||||
{ "GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions },
|
{ "GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions },
|
||||||
{ "GL_ATI_texture_env_combine3", NULL },
|
{ "GL_ATI_texture_env_combine3", NULL },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
|
@@ -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
|
void
|
||||||
_mesa_initialize_array_object( GLcontext *ctx,
|
_mesa_initialize_array_object( GLcontext *ctx,
|
||||||
struct gl_array_object *obj,
|
struct gl_array_object *obj,
|
||||||
@@ -107,87 +129,23 @@ _mesa_initialize_array_object( GLcontext *ctx,
|
|||||||
|
|
||||||
obj->Name = name;
|
obj->Name = name;
|
||||||
|
|
||||||
/* Vertex arrays */
|
/* Init the individual arrays */
|
||||||
obj->Vertex.Size = 4;
|
init_array(ctx, &obj->Vertex, 4, GL_FLOAT);
|
||||||
obj->Vertex.Type = GL_FLOAT;
|
init_array(ctx, &obj->Normal, 3, GL_FLOAT);
|
||||||
obj->Vertex.Stride = 0;
|
init_array(ctx, &obj->Color, 4, GL_FLOAT);
|
||||||
obj->Vertex.StrideB = 0;
|
init_array(ctx, &obj->SecondaryColor, 4, GL_FLOAT);
|
||||||
obj->Vertex.Ptr = NULL;
|
init_array(ctx, &obj->FogCoord, 1, GL_FLOAT);
|
||||||
obj->Vertex.Enabled = GL_FALSE;
|
init_array(ctx, &obj->Index, 1, GL_FLOAT);
|
||||||
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;
|
|
||||||
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
||||||
obj->TexCoord[i].Size = 4;
|
init_array(ctx, &obj->TexCoord[i], 4, GL_FLOAT);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
obj->EdgeFlag.Stride = 0;
|
init_array(ctx, &obj->EdgeFlag, 1, GL_BOOL);
|
||||||
obj->EdgeFlag.StrideB = 0;
|
|
||||||
obj->EdgeFlag.Ptr = NULL;
|
|
||||||
obj->EdgeFlag.Enabled = GL_FALSE;
|
|
||||||
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
|
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
|
||||||
obj->VertexAttrib[i].Size = 4;
|
init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FEATURE_point_size_array
|
#if FEATURE_point_size_array
|
||||||
obj->PointSize.Type = GL_FLOAT;
|
init_array(ctx, &obj->PointSize, 1, 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;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -129,6 +129,7 @@ static const struct {
|
|||||||
{ OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
|
{ OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
|
||||||
{ OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
|
{ OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
|
||||||
{ ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
|
{ 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_EXT_vertex_array_set", F(EXT_vertex_array_set) },
|
||||||
{ OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
|
{ OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
|
||||||
{ OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
|
{ OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
|
||||||
@@ -271,6 +272,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
|
|||||||
#if FEATURE_EXT_texture_sRGB
|
#if FEATURE_EXT_texture_sRGB
|
||||||
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
|
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
|
||||||
ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;
|
ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;
|
||||||
ctx->Extensions.MESA_pack_invert = GL_TRUE;
|
ctx->Extensions.MESA_pack_invert = GL_TRUE;
|
||||||
#if FEATURE_MESA_program_debug
|
#if FEATURE_MESA_program_debug
|
||||||
|
@@ -1675,6 +1675,7 @@ struct gl_client_array
|
|||||||
{
|
{
|
||||||
GLint Size; /**< components per element (1,2,3,4) */
|
GLint Size; /**< components per element (1,2,3,4) */
|
||||||
GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
|
GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
|
||||||
|
GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */
|
||||||
GLsizei Stride; /**< user-specified stride */
|
GLsizei Stride; /**< user-specified stride */
|
||||||
GLsizei StrideB; /**< actual stride in bytes */
|
GLsizei StrideB; /**< actual stride in bytes */
|
||||||
const GLubyte *Ptr; /**< Points to array data */
|
const GLubyte *Ptr; /**< Points to array data */
|
||||||
@@ -2625,6 +2626,7 @@ struct gl_extensions
|
|||||||
GLboolean EXT_texture_sRGB;
|
GLboolean EXT_texture_sRGB;
|
||||||
GLboolean EXT_timer_query;
|
GLboolean EXT_timer_query;
|
||||||
GLboolean EXT_vertex_array;
|
GLboolean EXT_vertex_array;
|
||||||
|
GLboolean EXT_vertex_array_bgra;
|
||||||
GLboolean EXT_vertex_array_set;
|
GLboolean EXT_vertex_array_set;
|
||||||
/* vendor extensions */
|
/* vendor extensions */
|
||||||
GLboolean APPLE_client_storage;
|
GLboolean APPLE_client_storage;
|
||||||
|
@@ -52,11 +52,13 @@
|
|||||||
static void
|
static void
|
||||||
update_array(GLcontext *ctx, struct gl_client_array *array,
|
update_array(GLcontext *ctx, struct gl_client_array *array,
|
||||||
GLbitfield dirtyBit, GLsizei elementSize,
|
GLbitfield dirtyBit, GLsizei elementSize,
|
||||||
GLint size, GLenum type,
|
GLint size, GLenum type, GLenum format,
|
||||||
GLsizei stride, GLboolean normalized, const GLvoid *ptr)
|
GLsizei stride, GLboolean normalized, const GLvoid *ptr)
|
||||||
{
|
{
|
||||||
|
ASSERT(format == GL_RGBA || format == GL_BGRA);
|
||||||
array->Size = size;
|
array->Size = size;
|
||||||
array->Type = type;
|
array->Type = type;
|
||||||
|
array->Format = format;
|
||||||
array->Stride = stride;
|
array->Stride = stride;
|
||||||
array->StrideB = stride ? stride : elementSize;
|
array->StrideB = stride ? stride : elementSize;
|
||||||
array->Normalized = normalized;
|
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,
|
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)
|
if (ctx->Driver.VertexPointer)
|
||||||
ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
|
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,
|
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)
|
if (ctx->Driver.NormalPointer)
|
||||||
ctx->Driver.NormalPointer( ctx, type, stride, ptr );
|
ctx->Driver.NormalPointer( ctx, type, stride, ptr );
|
||||||
@@ -193,13 +195,16 @@ void GLAPIENTRY
|
|||||||
_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
|
_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
|
||||||
{
|
{
|
||||||
GLsizei elementSize;
|
GLsizei elementSize;
|
||||||
|
GLenum format;
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||||
|
|
||||||
if (size < 3 || size > 4) {
|
if (size < 3 || size > 4) {
|
||||||
_mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
|
if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(size)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (stride < 0) {
|
if (stride < 0) {
|
||||||
_mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
|
_mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
|
||||||
return;
|
return;
|
||||||
@@ -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_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size,
|
||||||
_mesa_lookup_enum_by_nr( type ), stride);
|
_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) {
|
switch (type) {
|
||||||
case GL_BYTE:
|
case GL_BYTE:
|
||||||
elementSize = size * sizeof(GLbyte);
|
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,
|
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)
|
if (ctx->Driver.ColorPointer)
|
||||||
ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
|
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,
|
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)
|
if (ctx->Driver.FogCoordPointer)
|
||||||
ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
|
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,
|
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)
|
if (ctx->Driver.IndexPointer)
|
||||||
ctx->Driver.IndexPointer( ctx, type, stride, ptr );
|
ctx->Driver.IndexPointer( ctx, type, stride, ptr );
|
||||||
@@ -330,13 +347,16 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
|
|||||||
GLsizei stride, const GLvoid *ptr)
|
GLsizei stride, const GLvoid *ptr)
|
||||||
{
|
{
|
||||||
GLsizei elementSize;
|
GLsizei elementSize;
|
||||||
|
GLenum format;
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
|
||||||
|
|
||||||
if (size != 3 && size != 4) {
|
if (size != 3 && size != 4) {
|
||||||
_mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)" );
|
if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (stride < 0) {
|
if (stride < 0) {
|
||||||
_mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" );
|
_mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" );
|
||||||
return;
|
return;
|
||||||
@@ -346,6 +366,18 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
|
|||||||
_mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
|
_mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
|
||||||
size, _mesa_lookup_enum_by_nr( type ), stride);
|
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) {
|
switch (type) {
|
||||||
case GL_BYTE:
|
case GL_BYTE:
|
||||||
elementSize = size * sizeof(GLbyte);
|
elementSize = size * sizeof(GLbyte);
|
||||||
@@ -377,7 +409,7 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1,
|
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)
|
if (ctx->Driver.SecondaryColorPointer)
|
||||||
ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
|
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],
|
update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
|
||||||
_NEW_ARRAY_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)
|
if (ctx->Driver.TexCoordPointer)
|
||||||
ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
|
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,
|
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)
|
if (ctx->Driver.EdgeFlagPointer)
|
||||||
ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
|
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,
|
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],
|
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
|
||||||
_NEW_ARRAY_ATTRIB(index),
|
_NEW_ARRAY_ATTRIB(index),
|
||||||
elementSize, size, type, stride, normalized, ptr);
|
elementSize, size, type, GL_RGBA, stride, normalized, ptr);
|
||||||
|
|
||||||
if (ctx->Driver.VertexAttribPointer)
|
if (ctx->Driver.VertexAttribPointer)
|
||||||
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
|
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 stride, const GLvoid *ptr)
|
||||||
{
|
{
|
||||||
GLsizei elementSize;
|
GLsizei elementSize;
|
||||||
|
GLenum format;
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
@@ -570,15 +604,31 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (size < 1 || size > 4) {
|
if (size < 1 || size > 4) {
|
||||||
|
if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) {
|
||||||
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)");
|
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (stride < 0) {
|
if (stride < 0) {
|
||||||
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)");
|
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)");
|
||||||
return;
|
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 */
|
/* check for valid 'type' and compute StrideB right away */
|
||||||
/* NOTE: more types are supported here than in the NV extension */
|
/* NOTE: more types are supported here than in the NV extension */
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -618,7 +668,7 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
|
|||||||
|
|
||||||
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
|
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
|
||||||
_NEW_ARRAY_ATTRIB(index),
|
_NEW_ARRAY_ATTRIB(index),
|
||||||
elementSize, size, type, stride, normalized, ptr);
|
elementSize, size, type, GL_RGBA, stride, normalized, ptr);
|
||||||
|
|
||||||
if (ctx->Driver.VertexAttribPointer)
|
if (ctx->Driver.VertexAttribPointer)
|
||||||
ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
|
ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
|
||||||
|
@@ -88,6 +88,29 @@ static void free_space(GLcontext *ctx)
|
|||||||
} while (0)
|
} 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
|
/* Adjust pointer to point at first requested element, convert to
|
||||||
* floating point, populate VB->AttribPtr[].
|
* floating point, populate VB->AttribPtr[].
|
||||||
@@ -112,7 +135,13 @@ static void _tnl_import_array( GLcontext *ctx,
|
|||||||
CONVERT(GLbyte, BYTE_TO_FLOAT);
|
CONVERT(GLbyte, BYTE_TO_FLOAT);
|
||||||
break;
|
break;
|
||||||
case GL_UNSIGNED_BYTE:
|
case GL_UNSIGNED_BYTE:
|
||||||
|
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);
|
CONVERT(GLubyte, UBYTE_TO_FLOAT);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GL_SHORT:
|
case GL_SHORT:
|
||||||
CONVERT(GLshort, SHORT_TO_FLOAT);
|
CONVERT(GLshort, SHORT_TO_FLOAT);
|
||||||
|
Reference in New Issue
Block a user