aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/api_arrayelt.c40
-rw-r--r--mesalib/src/mesa/main/api_validate.c20
-rw-r--r--mesalib/src/mesa/main/arrayobj.c100
-rw-r--r--mesalib/src/mesa/main/attrib.c20
-rw-r--r--mesalib/src/mesa/main/bufferobj.c26
-rw-r--r--mesalib/src/mesa/main/bufferobj.h2
-rw-r--r--mesalib/src/mesa/main/context.c3
-rw-r--r--mesalib/src/mesa/main/enable.c66
-rw-r--r--mesalib/src/mesa/main/fbobject.c48
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp8
-rw-r--r--mesalib/src/mesa/main/ffvertex_prog.c20
-rw-r--r--mesalib/src/mesa/main/format_unpack.c19
-rw-r--r--mesalib/src/mesa/main/formats.c36
-rw-r--r--mesalib/src/mesa/main/formats.h20
-rw-r--r--mesalib/src/mesa/main/get.c106
-rw-r--r--mesalib/src/mesa/main/getstring.c18
-rw-r--r--mesalib/src/mesa/main/image.c91
-rw-r--r--mesalib/src/mesa/main/image.h3
-rw-r--r--mesalib/src/mesa/main/mipmap.c81
-rw-r--r--mesalib/src/mesa/main/mtypes.h211
-rw-r--r--mesalib/src/mesa/main/nvprogram.c8
-rw-r--r--mesalib/src/mesa/main/pack.c4
-rw-r--r--mesalib/src/mesa/main/state.c87
-rw-r--r--mesalib/src/mesa/main/state.h2
-rw-r--r--mesalib/src/mesa/main/texformat.c9
-rw-r--r--mesalib/src/mesa/main/texgetimage.c267
-rw-r--r--mesalib/src/mesa/main/teximage.c1
-rw-r--r--mesalib/src/mesa/main/texparam.c96
-rw-r--r--mesalib/src/mesa/main/texstore.c262
-rw-r--r--mesalib/src/mesa/main/varray.c112
30 files changed, 959 insertions, 827 deletions
diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c
index b93a057e6..7bf55f319 100644
--- a/mesalib/src/mesa/main/api_arrayelt.c
+++ b/mesalib/src/mesa/main/api_arrayelt.c
@@ -1474,44 +1474,44 @@ static void _ae_update_state( struct gl_context *ctx )
actx->nr_vbos = 0;
/* conventional vertex arrays */
- if (arrayObj->Index.Enabled) {
- aa->array = &arrayObj->Index;
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
+ aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
- if (arrayObj->EdgeFlag.Enabled) {
- aa->array = &arrayObj->EdgeFlag;
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
+ aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG];
aa->offset = _gloffset_EdgeFlagv;
check_vbo(actx, aa->array->BufferObj);
aa++;
}
- if (arrayObj->Normal.Enabled) {
- aa->array = &arrayObj->Normal;
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
+ aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL];
aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
- if (arrayObj->Color.Enabled) {
- aa->array = &arrayObj->Color;
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
+ aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0];
aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
- if (arrayObj->SecondaryColor.Enabled) {
- aa->array = &arrayObj->SecondaryColor;
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
+ aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1];
aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
- if (arrayObj->FogCoord.Enabled) {
- aa->array = &arrayObj->FogCoord;
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
+ aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_FOG];
aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- struct gl_client_array *attribArray = &arrayObj->TexCoord[i];
+ struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)];
if (attribArray->Enabled) {
/* NOTE: we use generic glVertexAttribNV functions here.
* If we ever remove GL_NV_vertex_program this will have to change.
@@ -1528,8 +1528,8 @@ static void _ae_update_state( struct gl_context *ctx )
}
/* generic vertex attribute arrays */
- for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) { /* skip zero! */
- struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i];
+ for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { /* skip zero! */
+ struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
if (attribArray->Enabled) {
at->array = attribArray;
/* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
@@ -1563,24 +1563,24 @@ static void _ae_update_state( struct gl_context *ctx )
}
/* finally, vertex position */
- if (arrayObj->VertexAttrib[0].Enabled) {
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
/* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
* issued as the last (provoking) attribute).
*/
- aa->array = &arrayObj->VertexAttrib[0];
+ aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0];
assert(aa->array->Size >= 2); /* XXX fix someday? */
aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
- else if (arrayObj->Vertex.Enabled) {
- aa->array = &arrayObj->Vertex;
+ else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
+ aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_POS];
aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
check_vbo(actx, aa->array->BufferObj);
aa++;
}
- check_vbo(actx, ctx->Array.ElementArrayBufferObj);
+ check_vbo(actx, arrayObj->ElementArrayBufferObj);
ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
ASSERT(aa - actx->arrays < 32);
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c
index 1fcf5cd68..efdecb212 100644
--- a/mesalib/src/mesa/main/api_validate.c
+++ b/mesalib/src/mesa/main/api_validate.c
@@ -120,7 +120,7 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
case API_OPENGLES:
/* For OpenGL ES, only draw if we have vertex positions
*/
- if (!ctx->Array.ArrayObj->Vertex.Enabled)
+ if (!ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled)
return GL_FALSE;
break;
#endif
@@ -142,8 +142,8 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
/* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
* array [0]).
*/
- return (ctx->Array.ArrayObj->Vertex.Enabled ||
- ctx->Array.ArrayObj->VertexAttrib[0].Enabled);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled ||
+ ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled);
}
}
break;
@@ -182,7 +182,7 @@ check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type,
memset(&ib, 0, sizeof(ib));
ib.type = type;
ib.ptr = indices;
- ib.obj = ctx->Array.ElementArrayBufferObj;
+ ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
vbo_get_minmax_index(ctx, &prim, &ib, &min, &max);
@@ -254,10 +254,10 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
return GL_FALSE;
/* Vertex buffer object tests */
- if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
+ if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
/* use indices in the buffer object */
/* make sure count doesn't go outside buffer bounds */
- if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) {
+ if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
_mesa_warning(ctx, "glDrawElements index out of buffer bounds");
return GL_FALSE;
}
@@ -315,10 +315,10 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode,
return GL_FALSE;
/* Vertex buffer object tests */
- if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
+ if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
/* use indices in the buffer object */
/* make sure count doesn't go outside buffer bounds */
- if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) {
+ if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
_mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds");
return GL_FALSE;
}
@@ -454,10 +454,10 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx,
return GL_FALSE;
/* Vertex buffer object tests */
- if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
+ if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
/* use indices in the buffer object */
/* make sure count doesn't go outside buffer bounds */
- if (index_bytes(type, count) > ctx->Array.ElementArrayBufferObj->Size) {
+ if (index_bytes(type, count) > ctx->Array.ArrayObj->ElementArrayBufferObj->Size) {
_mesa_warning(ctx,
"glDrawElementsInstanced index out of buffer bounds");
return GL_FALSE;
diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c
index 1283940f7..0439063b1 100644
--- a/mesalib/src/mesa/main/arrayobj.c
+++ b/mesalib/src/mesa/main/arrayobj.c
@@ -85,24 +85,8 @@ unbind_array_object_vbos(struct gl_context *ctx, struct gl_array_object *obj)
{
GLuint i;
- _mesa_reference_buffer_object(ctx, &obj->Vertex.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &obj->Weight.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &obj->Normal.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &obj->Color.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &obj->SecondaryColor.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &obj->FogCoord.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &obj->Index.BufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &obj->EdgeFlag.BufferObj, NULL);
-
- for (i = 0; i < Elements(obj->TexCoord); i++)
- _mesa_reference_buffer_object(ctx, &obj->TexCoord[i].BufferObj, NULL);
-
for (i = 0; i < Elements(obj->VertexAttrib); i++)
- _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj,NULL);
-
-#if FEATURE_point_size_array
- _mesa_reference_buffer_object(ctx, &obj->PointSize.BufferObj, NULL);
-#endif
+ _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj, NULL);
}
@@ -133,6 +117,7 @@ _mesa_delete_array_object( struct gl_context *ctx, struct gl_array_object *obj )
{
(void) ctx;
unbind_array_object_vbos(ctx, obj);
+ _mesa_reference_buffer_object(ctx, &obj->ElementArrayBufferObj, NULL);
_glthread_DESTROY_MUTEX(obj->Mutex);
free(obj);
}
@@ -234,24 +219,39 @@ _mesa_initialize_array_object( struct gl_context *ctx,
obj->RefCount = 1;
/* Init the individual arrays */
- init_array(ctx, &obj->Vertex, 4, GL_FLOAT);
- init_array(ctx, &obj->Weight, 1, GL_FLOAT);
- init_array(ctx, &obj->Normal, 3, GL_FLOAT);
- init_array(ctx, &obj->Color, 4, GL_FLOAT);
- init_array(ctx, &obj->SecondaryColor, 3, GL_FLOAT);
- init_array(ctx, &obj->FogCoord, 1, GL_FLOAT);
- init_array(ctx, &obj->Index, 1, GL_FLOAT);
- for (i = 0; i < Elements(obj->TexCoord); i++) {
- init_array(ctx, &obj->TexCoord[i], 4, GL_FLOAT);
- }
- init_array(ctx, &obj->EdgeFlag, 1, GL_BOOL);
for (i = 0; i < Elements(obj->VertexAttrib); i++) {
- init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT);
- }
-
+ switch (i) {
+ case VERT_ATTRIB_WEIGHT:
+ init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_WEIGHT], 1, GL_FLOAT);
+ break;
+ case VERT_ATTRIB_NORMAL:
+ init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_NORMAL], 3, GL_FLOAT);
+ break;
+ case VERT_ATTRIB_COLOR1:
+ init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_COLOR1], 3, GL_FLOAT);
+ break;
+ case VERT_ATTRIB_FOG:
+ init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_FOG], 1, GL_FLOAT);
+ break;
+ case VERT_ATTRIB_COLOR_INDEX:
+ init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX], 1, GL_FLOAT);
+ break;
+ case VERT_ATTRIB_EDGEFLAG:
+ init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_EDGEFLAG], 1, GL_BOOL);
+ break;
#if FEATURE_point_size_array
- init_array(ctx, &obj->PointSize, 1, GL_FLOAT);
+ case VERT_ATTRIB_POINT_SIZE:
+ init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_POINT_SIZE], 1, GL_FLOAT);
+ break;
#endif
+ default:
+ init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT);
+ break;
+ }
+ }
+
+ _mesa_reference_buffer_object(ctx, &obj->ElementArrayBufferObj,
+ ctx->Shared->NullBufferObj);
}
@@ -290,12 +290,9 @@ remove_array_object( struct gl_context *ctx, struct gl_array_object *obj )
static GLuint
update_min(GLuint min, struct gl_client_array *array)
{
- if (array->Enabled) {
- _mesa_update_array_max_element(array);
- return MIN2(min, array->_MaxElement);
- }
- else
- return min;
+ assert(array->Enabled);
+ _mesa_update_array_max_element(array);
+ return MIN2(min, array->_MaxElement);
}
@@ -306,23 +303,14 @@ void
_mesa_update_array_object_max_element(struct gl_context *ctx,
struct gl_array_object *arrayObj)
{
- GLuint i, min = ~0;
-
- min = update_min(min, &arrayObj->Vertex);
- min = update_min(min, &arrayObj->Weight);
- min = update_min(min, &arrayObj->Normal);
- min = update_min(min, &arrayObj->Color);
- min = update_min(min, &arrayObj->SecondaryColor);
- min = update_min(min, &arrayObj->FogCoord);
- min = update_min(min, &arrayObj->Index);
- min = update_min(min, &arrayObj->EdgeFlag);
-#if FEATURE_point_size_array
- min = update_min(min, &arrayObj->PointSize);
-#endif
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
- min = update_min(min, &arrayObj->TexCoord[i]);
- for (i = 0; i < Elements(arrayObj->VertexAttrib); i++)
- min = update_min(min, &arrayObj->VertexAttrib[i]);
+ GLbitfield64 enabled = arrayObj->_Enabled;
+ GLuint min = ~0u;
+
+ while (enabled) {
+ GLint attrib = _mesa_ffsll(enabled) - 1;
+ enabled &= ~BITFIELD64_BIT(attrib);
+ min = update_min(min, &arrayObj->VertexAttrib[attrib]);
+ }
/* _MaxElement is one past the last legal array element */
arrayObj->_MaxElement = min;
@@ -380,7 +368,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired)
}
ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_ALL;
+ ctx->Array.NewState |= VERT_BIT_ALL;
_mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, newObj);
/* Pass BindVertexArray call to device driver */
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index f368eecc1..6f4a91b1f 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -1322,19 +1322,6 @@ copy_array_object(struct gl_context *ctx,
/* In theory must be the same anyway, but on recreate make sure it matches */
dest->VBOonly = src->VBOonly;
- _mesa_copy_client_array(ctx, &dest->Vertex, &src->Vertex);
- _mesa_copy_client_array(ctx, &dest->Weight, &src->Weight);
- _mesa_copy_client_array(ctx, &dest->Normal, &src->Normal);
- _mesa_copy_client_array(ctx, &dest->Color, &src->Color);
- _mesa_copy_client_array(ctx, &dest->SecondaryColor, &src->SecondaryColor);
- _mesa_copy_client_array(ctx, &dest->FogCoord, &src->FogCoord);
- _mesa_copy_client_array(ctx, &dest->Index, &src->Index);
- _mesa_copy_client_array(ctx, &dest->EdgeFlag, &src->EdgeFlag);
-#if FEATURE_point_size_array
- _mesa_copy_client_array(ctx, &dest->PointSize, &src->PointSize);
-#endif
- for (i = 0; i < Elements(src->TexCoord); i++)
- _mesa_copy_client_array(ctx, &dest->TexCoord[i], &src->TexCoord[i]);
for (i = 0; i < Elements(src->VertexAttrib); i++)
_mesa_copy_client_array(ctx, &dest->VertexAttrib[i], &src->VertexAttrib[i]);
@@ -1385,8 +1372,8 @@ save_array_attrib(struct gl_context *ctx,
/* Just reference them here */
_mesa_reference_buffer_object(ctx, &dest->ArrayBufferObj,
src->ArrayBufferObj);
- _mesa_reference_buffer_object(ctx, &dest->ElementArrayBufferObj,
- src->ElementArrayBufferObj);
+ _mesa_reference_buffer_object(ctx, &dest->ArrayObj->ElementArrayBufferObj,
+ src->ArrayObj->ElementArrayBufferObj);
}
/**
@@ -1407,7 +1394,7 @@ restore_array_attrib(struct gl_context *ctx,
_mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB,
src->ArrayBufferObj->Name);
_mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
- src->ElementArrayBufferObj->Name);
+ src->ArrayObj->ElementArrayBufferObj->Name);
/* Better safe than sorry?! */
dest->RebindArrays = GL_TRUE;
@@ -1447,7 +1434,6 @@ free_array_attrib_data(struct gl_context *ctx,
_mesa_delete_array_object(ctx, attrib->ArrayObj);
attrib->ArrayObj = 0;
_mesa_reference_buffer_object(ctx, &attrib->ArrayBufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &attrib->ElementArrayBufferObj, NULL);
}
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index f2e8f568c..9e6f56b14 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -77,7 +77,7 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
case GL_ARRAY_BUFFER_ARB:
return &ctx->Array.ArrayBufferObj;
case GL_ELEMENT_ARRAY_BUFFER_ARB:
- return &ctx->Array.ElementArrayBufferObj;
+ return &ctx->Array.ArrayObj->ElementArrayBufferObj;
case GL_PIXEL_PACK_BUFFER_EXT:
return &ctx->Pack.BufferObj;
case GL_PIXEL_UNPACK_BUFFER_EXT:
@@ -270,7 +270,7 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
#if 0
/* unfortunately, these tests are invalid during context tear-down */
ASSERT(ctx->Array.ArrayBufferObj != bufObj);
- ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
+ ASSERT(ctx->Array.ArrayObj->ElementArrayBufferObj != bufObj);
ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj);
#endif
@@ -531,8 +531,6 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
_mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj,
ctx->Shared->NullBufferObj);
- _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj,
- ctx->Shared->NullBufferObj);
_mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer,
ctx->Shared->NullBufferObj);
@@ -545,7 +543,6 @@ void
_mesa_free_buffer_objects( struct gl_context *ctx )
{
_mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL);
_mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, NULL);
_mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, NULL);
@@ -741,17 +738,6 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
}
/* unbind any vertex pointers bound to this buffer */
- unbind(ctx, &arrayObj->Vertex.BufferObj, bufObj);
- unbind(ctx, &arrayObj->Weight.BufferObj, bufObj);
- unbind(ctx, &arrayObj->Normal.BufferObj, bufObj);
- unbind(ctx, &arrayObj->Color.BufferObj, bufObj);
- unbind(ctx, &arrayObj->SecondaryColor.BufferObj, bufObj);
- unbind(ctx, &arrayObj->FogCoord.BufferObj, bufObj);
- unbind(ctx, &arrayObj->Index.BufferObj, bufObj);
- unbind(ctx, &arrayObj->EdgeFlag.BufferObj, bufObj);
- for (j = 0; j < Elements(arrayObj->TexCoord); j++) {
- unbind(ctx, &arrayObj->TexCoord[j].BufferObj, bufObj);
- }
for (j = 0; j < Elements(arrayObj->VertexAttrib); j++) {
unbind(ctx, &arrayObj->VertexAttrib[j].BufferObj, bufObj);
}
@@ -759,7 +745,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
if (ctx->Array.ArrayBufferObj == bufObj) {
_mesa_BindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
}
- if (ctx->Array.ElementArrayBufferObj == bufObj) {
+ if (arrayObj->ElementArrayBufferObj == bufObj) {
_mesa_BindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
}
@@ -1286,14 +1272,14 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
ASSERT_OUTSIDE_BEGIN_END(ctx);
src = get_buffer(ctx, readTarget);
- if (!src || !_mesa_is_bufferobj(src)) {
+ if (!_mesa_is_bufferobj(src)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glCopyBuffserSubData(readTarget = 0x%x)", readTarget);
return;
}
dst = get_buffer(ctx, writeTarget);
- if (!dst || !_mesa_is_bufferobj(dst)) {
+ if (!_mesa_is_bufferobj(dst)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glCopyBuffserSubData(writeTarget = 0x%x)", writeTarget);
return;
@@ -1421,7 +1407,7 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
}
bufObj = get_buffer(ctx, target);
- if (!bufObj || !_mesa_is_bufferobj(bufObj)) {
+ if (!_mesa_is_bufferobj(bufObj)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glMapBufferRange(target = 0x%x)", target);
return NULL;
diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h
index b4e70f2f0..c0d5a641a 100644
--- a/mesalib/src/mesa/main/bufferobj.h
+++ b/mesalib/src/mesa/main/bufferobj.h
@@ -53,7 +53,7 @@ _mesa_bufferobj_mapped(const struct gl_buffer_object *obj)
static inline GLboolean
_mesa_is_bufferobj(const struct gl_buffer_object *obj)
{
- return obj->Name != 0;
+ return obj != NULL && obj->Name != 0;
}
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index e0af6ee67..009048170 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -798,7 +798,7 @@ init_attrib_groups(struct gl_context *ctx)
ctx->NewState = _NEW_ALL;
ctx->ErrorValue = (GLenum) GL_NO_ERROR;
ctx->ResetStatus = (GLenum) GL_NO_ERROR;
- ctx->varying_vp_inputs = ~0;
+ ctx->varying_vp_inputs = VERT_BIT_ALL;
return GL_TRUE;
}
@@ -1135,7 +1135,6 @@ _mesa_free_context_data( struct gl_context *ctx )
#if FEATURE_ARB_vertex_buffer_object
_mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL);
- _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj, NULL);
#endif
/* free dispatch tables */
diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c
index b2c77243b..6461ac1b3 100644
--- a/mesalib/src/mesa/main/enable.c
+++ b/mesalib/src/mesa/main/enable.c
@@ -54,47 +54,47 @@ static void
client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
{
struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
- GLuint flag;
+ GLbitfield64 flag;
GLboolean *var;
switch (cap) {
case GL_VERTEX_ARRAY:
- var = &arrayObj->Vertex.Enabled;
- flag = _NEW_ARRAY_VERTEX;
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled;
+ flag = VERT_BIT_POS;
break;
case GL_NORMAL_ARRAY:
- var = &arrayObj->Normal.Enabled;
- flag = _NEW_ARRAY_NORMAL;
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
+ flag = VERT_BIT_NORMAL;
break;
case GL_COLOR_ARRAY:
- var = &arrayObj->Color.Enabled;
- flag = _NEW_ARRAY_COLOR0;
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
+ flag = VERT_BIT_COLOR0;
break;
case GL_INDEX_ARRAY:
- var = &arrayObj->Index.Enabled;
- flag = _NEW_ARRAY_INDEX;
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
+ flag = VERT_BIT_COLOR_INDEX;
break;
case GL_TEXTURE_COORD_ARRAY:
- var = &arrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled;
- flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture);
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled;
+ flag = VERT_BIT_TEX(ctx->Array.ActiveTexture);
break;
case GL_EDGE_FLAG_ARRAY:
- var = &arrayObj->EdgeFlag.Enabled;
- flag = _NEW_ARRAY_EDGEFLAG;
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
+ flag = VERT_BIT_EDGEFLAG;
break;
case GL_FOG_COORDINATE_ARRAY_EXT:
- var = &arrayObj->FogCoord.Enabled;
- flag = _NEW_ARRAY_FOGCOORD;
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
+ flag = VERT_BIT_FOG;
break;
case GL_SECONDARY_COLOR_ARRAY_EXT:
- var = &arrayObj->SecondaryColor.Enabled;
- flag = _NEW_ARRAY_COLOR1;
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
+ flag = VERT_BIT_COLOR1;
break;
#if FEATURE_point_size_array
case GL_POINT_SIZE_ARRAY_OES:
- var = &arrayObj->PointSize.Enabled;
- flag = _NEW_ARRAY_POINT_SIZE;
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
+ flag = VERT_BIT_POINT_SIZE;
break;
#endif
@@ -118,9 +118,9 @@ client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
CHECK_EXTENSION(NV_vertex_program, cap);
{
GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
- ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib));
- var = &arrayObj->VertexAttrib[n].Enabled;
- flag = _NEW_ARRAY_ATTRIB(n);
+ ASSERT(VERT_ATTRIB_GENERIC(n) < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ var = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(n)].Enabled;
+ flag = VERT_BIT_GENERIC(n);
}
break;
#endif /* FEATURE_NV_vertex_program */
@@ -1226,27 +1226,27 @@ _mesa_IsEnabled( GLenum cap )
/* client-side state */
case GL_VERTEX_ARRAY:
- return (ctx->Array.ArrayObj->Vertex.Enabled != 0);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled != 0);
case GL_NORMAL_ARRAY:
- return (ctx->Array.ArrayObj->Normal.Enabled != 0);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled != 0);
case GL_COLOR_ARRAY:
- return (ctx->Array.ArrayObj->Color.Enabled != 0);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled != 0);
case GL_INDEX_ARRAY:
- return (ctx->Array.ArrayObj->Index.Enabled != 0);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled != 0);
case GL_TEXTURE_COORD_ARRAY:
- return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture]
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)]
.Enabled != 0);
case GL_EDGE_FLAG_ARRAY:
- return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled != 0);
case GL_FOG_COORDINATE_ARRAY_EXT:
CHECK_EXTENSION(EXT_fog_coord);
- return (ctx->Array.ArrayObj->FogCoord.Enabled != 0);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled != 0);
case GL_SECONDARY_COLOR_ARRAY_EXT:
CHECK_EXTENSION(EXT_secondary_color);
- return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled != 0);
#if FEATURE_point_size_array
case GL_POINT_SIZE_ARRAY_OES:
- return (ctx->Array.ArrayObj->PointSize.Enabled != 0);
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled != 0);
#endif
/* GL_ARB_texture_cube_map */
@@ -1312,8 +1312,8 @@ _mesa_IsEnabled( GLenum cap )
CHECK_EXTENSION(NV_vertex_program);
{
GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
- ASSERT(n < Elements(ctx->Array.ArrayObj->VertexAttrib));
- return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0);
+ ASSERT(VERT_ATTRIB_GENERIC(n) < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(n)].Enabled != 0);
}
case GL_MAP1_VERTEX_ATTRIB0_4_NV:
case GL_MAP1_VERTEX_ATTRIB1_4_NV:
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 5b329f5c3..9111caa1b 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -39,6 +39,7 @@
#include "formats.h"
#include "framebuffer.h"
#include "hash.h"
+#include "image.h"
#include "macros.h"
#include "mfeatures.h"
#include "mtypes.h"
@@ -1299,6 +1300,9 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
case GL_LUMINANCE_ALPHA32UI_EXT:
return ctx->Extensions.EXT_texture_integer &&
ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0;
+
+ case GL_RGB10_A2UI:
+ return ctx->Extensions.ARB_texture_rgb10_a2ui ? GL_RGBA : 0;
default:
return 0;
}
@@ -1474,48 +1478,10 @@ _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
static GLint
get_component_bits(GLenum pname, GLenum baseFormat, gl_format format)
{
- switch (pname) {
- case GL_RENDERBUFFER_RED_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
- if (baseFormat == GL_RGB || baseFormat == GL_RGBA ||
- baseFormat == GL_RG || baseFormat == GL_RED)
- return _mesa_get_format_bits(format, pname);
- else
- return 0;
- case GL_RENDERBUFFER_GREEN_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
- if (baseFormat == GL_RGB || baseFormat == GL_RGBA || baseFormat == GL_RG)
- return _mesa_get_format_bits(format, pname);
- else
- return 0;
- case GL_RENDERBUFFER_BLUE_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
- if (baseFormat == GL_RGB || baseFormat == GL_RGBA)
- return _mesa_get_format_bits(format, pname);
- else
- return 0;
- case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
- if (baseFormat == GL_RGBA || baseFormat == GL_ALPHA ||
- baseFormat == GL_LUMINANCE_ALPHA)
- return _mesa_get_format_bits(format, pname);
- else
- return 0;
- case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
- if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL)
- return _mesa_get_format_bits(format, pname);
- else
- return 0;
- case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
- case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
- if (baseFormat == GL_STENCIL_INDEX || baseFormat == GL_DEPTH_STENCIL)
- return _mesa_get_format_bits(format, pname);
- else
- return 0;
- default:
+ if (_mesa_base_format_has_channel(baseFormat, pname))
+ return _mesa_get_format_bits(format, pname);
+ else
return 0;
- }
}
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index 2ce81fef6..008da0d0e 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -334,7 +334,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
else if (!(vertexProgram || vertexShader)) {
/* Fixed function vertex logic */
/* _NEW_ARRAY */
- GLbitfield varying_inputs = ctx->varying_vp_inputs;
+ GLbitfield64 varying_inputs = ctx->varying_vp_inputs;
/* These get generated in the setup routine regardless of the
* vertex program:
@@ -489,6 +489,12 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key )
/* _NEW_BUFFERS */
key->num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers;
+ /* _NEW_COLOR */
+ if (ctx->Color.AlphaEnabled && key->num_draw_buffers == 0) {
+ /* if alpha test is enabled we need to emit at least one color */
+ key->num_draw_buffers = 1;
+ }
+
key->inputs_available = (inputs_available & inputs_referenced);
/* compute size of state key, ignoring unused texture units */
diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c
index 2c937386a..19d319a56 100644
--- a/mesalib/src/mesa/main/ffvertex_prog.c
+++ b/mesalib/src/mesa/main/ffvertex_prog.c
@@ -68,7 +68,7 @@ struct state_key {
unsigned texture_enabled_global:1;
unsigned fragprog_inputs_read:12;
- unsigned varying_vp_inputs;
+ GLbitfield64 varying_vp_inputs;
struct {
unsigned light_enabled:1;
@@ -130,16 +130,16 @@ static GLboolean check_active_shininess( struct gl_context *ctx,
const struct state_key *key,
GLuint side )
{
- GLuint bit = 1 << (MAT_ATTRIB_FRONT_SHININESS + side);
+ GLuint attr = MAT_ATTRIB_FRONT_SHININESS + side;
if ((key->varying_vp_inputs & VERT_BIT_COLOR0) &&
- (key->light_color_material_mask & bit))
+ (key->light_color_material_mask & (1 << attr)))
return GL_TRUE;
- if (key->varying_vp_inputs & (bit << 16))
+ if (key->varying_vp_inputs & VERT_ATTRIB_GENERIC(attr))
return GL_TRUE;
- if (ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS + side][0] != 0.0F)
+ if (ctx->Light.Material.Attrib[attr][0] != 0.0F)
return GL_TRUE;
return GL_FALSE;
@@ -230,7 +230,7 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
key->point_attenuated = 1;
#if FEATURE_point_size_array
- if (ctx->Array.ArrayObj->PointSize.Enabled)
+ if (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled)
key->point_array = 1;
#endif
@@ -445,10 +445,10 @@ static struct ureg register_param5(struct tnl_program *p,
*/
static struct ureg register_input( struct tnl_program *p, GLuint input )
{
- assert(input < 32);
+ assert(input < VERT_ATTRIB_MAX);
- if (p->state->varying_vp_inputs & (1<<input)) {
- p->program->Base.InputsRead |= (1<<input);
+ if (p->state->varying_vp_inputs & VERT_BIT(input)) {
+ p->program->Base.InputsRead |= VERT_BIT(input);
return make_ureg(PROGRAM_INPUT, input);
}
else {
@@ -871,7 +871,7 @@ static void set_material_flags( struct tnl_program *p )
p->color_materials = p->state->light_color_material_mask;
}
- p->materials |= (p->state->varying_vp_inputs >> 16);
+ p->materials |= (p->state->varying_vp_inputs >> VERT_ATTRIB_GENERIC0);
}
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index 2f051dfa4..0ab694014 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -661,7 +661,7 @@ unpack_Z32_FLOAT(const void *src, GLfloat dst[][4], GLuint n)
for (i = 0; i < n; i++) {
dst[i][0] =
dst[i][1] =
- dst[i][2] = s[i];
+ dst[i][2] = s[i * 2];
dst[i][3] = 1.0F;
}
}
@@ -1642,6 +1642,20 @@ unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
}
}
+static void
+unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ GLuint tmp = src[i];
+ dst[i][0] = (tmp >> 20) & 0x3ff;
+ dst[i][1] = (tmp >> 10) & 0x3ff;
+ dst[i][2] = (tmp >> 0) & 0x3ff;
+ dst[i][3] = (tmp >> 30) & 0x3;
+ }
+}
+
void
_mesa_unpack_int_rgba_row(gl_format format, GLuint n,
const void *src, GLuint dst[][4])
@@ -1680,6 +1694,9 @@ _mesa_unpack_int_rgba_row(gl_format format, GLuint n,
unpack_int_rgba_INTENSITY_UINT32(src, dst, n);
break;
+ case MESA_FORMAT_ARGB2101010_UINT:
+ unpack_int_rgba_ARGB2101010_UINT(src, dst, n);
+ break;
default:
_mesa_problem(NULL, "%s: bad format %s", __FUNCTION__,
_mesa_get_format_name(format));
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index b9871aec8..d3b12d008 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -1496,6 +1496,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 32, 8, /* Lum/Int/Index/Depth/StencilBits */
1, 1, 8 /* BlockWidth/Height,Bytes */
},
+ {
+ MESA_FORMAT_ARGB2101010_UINT,
+ "MESA_FORMAT_ARGB2101010_UINT",
+ GL_RGBA,
+ GL_UNSIGNED_INT,
+ 10, 10, 10, 2,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
};
@@ -2449,6 +2458,11 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 3;
return;
+ case MESA_FORMAT_ARGB2101010_UINT:
+ *datatype = GL_UNSIGNED_INT_2_10_10_10_REV;
+ *comps = 4;
+ return;
+
case MESA_FORMAT_COUNT:
assert(0);
return;
@@ -2466,11 +2480,12 @@ _mesa_format_to_type_and_comps(gl_format format,
}
/**
- * Returns a MESA_FORMAT describing pixels with the given format/type if
- * available, or MESA_FORMAT_NONE.
+ * Check if a gl_format exactly matches a GL formaat/type combination
+ * such that we can use memcpy() from one to the other.
+ *
+ * Note: this matching assumes that GL_PACK/UNPACK_SWAP_BYTES is unset.
*
- * If a format is returned, it should be suitable to memcpy
- * _mesa_get_format_bytes() at a time to move the pixel data.
+ * \return GL_TRUE if the formats match, GL_FALSE otherwise.
*/
GLboolean
_mesa_format_matches_format_and_type(gl_format gl_format,
@@ -2480,13 +2495,11 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
/* Note: When reading a GL format/type combination, the format lists channel
* assignments from most significant channel in the type to least
- * significant. A type with _REV indicates that the assignments are swapped,
- * so they are listed from least significant to most significant.
+ * significant. A type with _REV indicates that the assignments are
+ * swapped, so they are listed from least significant to most significant.
*
- * For sanity, please keep this switch statement ordered the same as the enum
- * in formats.h.
- *
- * This matching assumes that GL_PACK/UNPACK_SWAP_BYTES is unset.
+ * For sanity, please keep this switch statement ordered the same as the
+ * enums in formats.h.
*/
switch (gl_format) {
@@ -2772,6 +2785,9 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
/* FINISHME: SNORM */
return GL_FALSE;
+ case MESA_FORMAT_ARGB2101010_UINT:
+ return GL_FALSE;
+
case MESA_FORMAT_RGB9_E5_FLOAT:
return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV;
case MESA_FORMAT_R11_G11_B10_FLOAT:
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index 5f601862b..b22b07338 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -91,11 +91,11 @@ typedef enum
MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
MESA_FORMAT_R8, /* RRRR RRRR */
- MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */
- MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */
+ MESA_FORMAT_RG88, /* GGGG GGGG RRRR RRRR */
+ MESA_FORMAT_RG88_REV, /* RRRR RRRR GGGG GGGG */
MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */
- MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */
- MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */
+ MESA_FORMAT_RG1616, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */
+ MESA_FORMAT_RG1616_REV, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */
MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */
MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
@@ -110,11 +110,11 @@ typedef enum
* \name 8-bit/channel sRGB formats
*/
/*@{*/
- MESA_FORMAT_SRGB8,
- MESA_FORMAT_SRGBA8,
- MESA_FORMAT_SARGB8,
- MESA_FORMAT_SL8,
- MESA_FORMAT_SLA8,
+ MESA_FORMAT_SRGB8, /* RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_FORMAT_SRGBA8, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
+ MESA_FORMAT_SARGB8, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_FORMAT_SL8, /* LLLL LLLL */
+ MESA_FORMAT_SLA8, /* AAAA AAAA LLLL LLLL */
MESA_FORMAT_SRGB_DXT1,
MESA_FORMAT_SRGBA_DXT1,
MESA_FORMAT_SRGBA_DXT3,
@@ -265,6 +265,8 @@ typedef enum
MESA_FORMAT_Z32_FLOAT,
MESA_FORMAT_Z32_FLOAT_X24S8,
+ MESA_FORMAT_ARGB2101010_UINT,
+
MESA_FORMAT_COUNT
} gl_format;
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index d8a063876..4df6afe36 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -589,17 +589,17 @@ static const struct value_desc values[] = {
{ GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0,
extra_valid_texture_unit },
- { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled), NO_EXTRA },
- { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size), NO_EXTRA },
- { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type), NO_EXTRA },
- { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride), NO_EXTRA },
- { GL_NORMAL_ARRAY, ARRAY_BOOL(Normal.Enabled), NO_EXTRA },
- { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type), NO_EXTRA },
- { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride), NO_EXTRA },
- { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled), NO_EXTRA },
- { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size), NO_EXTRA },
- { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type), NO_EXTRA },
- { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride), NO_EXTRA },
+ { GL_VERTEX_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_POS].Enabled), NO_EXTRA },
+ { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_POS].Size), NO_EXTRA },
+ { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_POS].Type), NO_EXTRA },
+ { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_POS].Stride), NO_EXTRA },
+ { GL_NORMAL_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_NORMAL].Enabled), NO_EXTRA },
+ { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_NORMAL].Type), NO_EXTRA },
+ { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_NORMAL].Stride), NO_EXTRA },
+ { GL_COLOR_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR0].Enabled), NO_EXTRA },
+ { GL_COLOR_ARRAY_SIZE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR0].Size), NO_EXTRA },
+ { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR0].Type), NO_EXTRA },
+ { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR0].Stride), NO_EXTRA },
{ GL_TEXTURE_COORD_ARRAY,
LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA },
{ GL_TEXTURE_COORD_ARRAY_SIZE,
@@ -634,11 +634,11 @@ static const struct value_desc values[] = {
/* GL_ARB_vertex_buffer_object */
{ GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, Vertex.BufferObj), NO_EXTRA },
+ offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_POS].BufferObj), NO_EXTRA },
{ GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, Normal.BufferObj), NO_EXTRA },
+ offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_NORMAL].BufferObj), NO_EXTRA },
{ GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, Color.BufferObj), NO_EXTRA },
+ offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_COLOR0].BufferObj), NO_EXTRA },
{ GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA },
/* GL_OES_point_sprite */
@@ -676,9 +676,9 @@ static const struct value_desc values[] = {
{ GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES },
/* OES_point_size_array */
- { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(PointSize.Enabled, TYPE_BOOLEAN) },
- { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(PointSize.Type, TYPE_ENUM) },
- { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(PointSize.Stride, TYPE_INT) },
+ { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled, TYPE_BOOLEAN) },
+ { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Type, TYPE_ENUM) },
+ { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Stride, TYPE_INT) },
{ GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 },
#endif /* FEATURE_ES1 */
@@ -927,13 +927,13 @@ static const struct value_desc values[] = {
{ GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
{ GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
{ GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
- { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled), NO_EXTRA },
- { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type), NO_EXTRA },
- { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride), NO_EXTRA },
+ { GL_INDEX_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled), NO_EXTRA },
+ { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Type), NO_EXTRA },
+ { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Stride), NO_EXTRA },
{ GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
{ GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
- { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled), NO_EXTRA },
- { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride), NO_EXTRA },
+ { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled), NO_EXTRA },
+ { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_EDGEFLAG].Stride), NO_EXTRA },
{ GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
/* GL_ARB_texture_compression */
@@ -958,24 +958,24 @@ static const struct value_desc values[] = {
{ GL_CURRENT_SECONDARY_COLOR_EXT,
CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4),
extra_EXT_secondary_color_flush_current },
- { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled),
+ { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR1].Enabled),
extra_EXT_secondary_color },
- { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type),
+ { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR1].Type),
extra_EXT_secondary_color },
- { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride),
+ { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR1].Stride),
extra_EXT_secondary_color },
- { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size),
+ { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR1].Size),
extra_EXT_secondary_color },
/* GL_EXT_fog_coord */
{ GL_CURRENT_FOG_COORDINATE_EXT,
CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]),
extra_EXT_fog_coord_flush_current },
- { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled),
+ { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_FOG].Enabled),
extra_EXT_fog_coord },
- { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type),
+ { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_FOG].Type),
extra_EXT_fog_coord },
- { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride),
+ { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(VertexAttrib[VERT_ATTRIB_FOG].Stride),
extra_EXT_fog_coord },
{ GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource),
extra_EXT_fog_coord },
@@ -998,37 +998,37 @@ static const struct value_desc values[] = {
/* GL_NV_vertex_program */
{ GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0,
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(0)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(1)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(2)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(3)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(4)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(5)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(6)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(7)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(8)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(9)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(10)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(11)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(12)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(13)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(14)].Enabled),
extra_NV_vertex_program },
- { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled),
+ { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(15)].Enabled),
extra_NV_vertex_program },
{ GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]),
extra_NV_vertex_program },
@@ -1099,13 +1099,13 @@ static const struct value_desc values[] = {
/* GL_ARB_vertex_buffer_object */
{ GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, Index.BufferObj), NO_EXTRA },
+ offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_COLOR_INDEX].BufferObj), NO_EXTRA },
{ GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, EdgeFlag.BufferObj), NO_EXTRA },
+ offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_EDGEFLAG].BufferObj), NO_EXTRA },
{ GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, SecondaryColor.BufferObj), NO_EXTRA },
+ offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_COLOR1].BufferObj), NO_EXTRA },
{ GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
- offsetof(struct gl_array_object, FogCoord.BufferObj), NO_EXTRA },
+ offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_FOG].BufferObj), NO_EXTRA },
/* GL_EXT_pixel_buffer_object */
{ GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
@@ -1487,7 +1487,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
case GL_TEXTURE_COORD_ARRAY_SIZE:
case GL_TEXTURE_COORD_ARRAY_TYPE:
case GL_TEXTURE_COORD_ARRAY_STRIDE:
- array = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture];
+ array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)];
v->value_int = *(GLuint *) ((char *) array + d->offset);
break;
@@ -1627,10 +1627,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
break;
case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
v->value_int =
- ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name;
+ ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj->Name;
break;
case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
- v->value_int = ctx->Array.ElementArrayBufferObj->Name;
+ v->value_int = ctx->Array.ArrayObj->ElementArrayBufferObj->Name;
break;
/* ARB_copy_buffer */
@@ -1679,7 +1679,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
break;
case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
- v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name;
+ v->value_int = ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].BufferObj->Name;
break;
case GL_FOG_COLOR:
diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c
index c381fb2df..dbf6c3f5e 100644
--- a/mesalib/src/mesa/main/getstring.c
+++ b/mesalib/src/mesa/main/getstring.c
@@ -190,28 +190,28 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params )
switch (pname) {
case GL_VERTEX_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->Vertex.Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Ptr;
break;
case GL_NORMAL_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->Normal.Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Ptr;
break;
case GL_COLOR_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->Color.Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Ptr;
break;
case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT:
- *params = (GLvoid *) ctx->Array.ArrayObj->SecondaryColor.Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Ptr;
break;
case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
- *params = (GLvoid *) ctx->Array.ArrayObj->FogCoord.Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Ptr;
break;
case GL_INDEX_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->Index.Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Ptr;
break;
case GL_TEXTURE_COORD_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->TexCoord[clientUnit].Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(clientUnit)].Ptr;
break;
case GL_EDGE_FLAG_ARRAY_POINTER:
- *params = (GLvoid *) ctx->Array.ArrayObj->EdgeFlag.Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Ptr;
break;
case GL_FEEDBACK_BUFFER_POINTER:
*params = ctx->Feedback.Buffer;
@@ -221,7 +221,7 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params )
break;
#if FEATURE_point_size_array
case GL_POINT_SIZE_ARRAY_POINTER_OES:
- *params = (GLvoid *) ctx->Array.ArrayObj->PointSize.Ptr;
+ *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Ptr;
break;
#endif
default:
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index ca31e53a8..9b9e83802 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -243,12 +243,14 @@ _mesa_components_in_format( GLenum format )
case GL_RGB:
case GL_BGR:
case GL_RGB_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
return 3;
case GL_RGBA:
case GL_BGRA:
case GL_ABGR_EXT:
case GL_RGBA_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
return 4;
default:
@@ -814,6 +816,7 @@ _mesa_is_color_format(GLenum format)
case GL_INTENSITY16_SNORM:
case GL_RGB9_E5:
case GL_R11F_G11F_B10F:
+ case GL_RGB10_A2UI:
return GL_TRUE;
case GL_YCBCR_MESA: /* not considered to be RGB */
/* fall-through */
@@ -1000,6 +1003,7 @@ _mesa_is_integer_format(GLenum format)
case GL_INTENSITY8I_EXT:
case GL_LUMINANCE8I_EXT:
case GL_LUMINANCE_ALPHA8I_EXT:
+ case GL_RGB10_A2UI:
return GL_TRUE;
default:
return GL_FALSE;
@@ -1067,6 +1071,93 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
/**
+ * Does the given base texture/renderbuffer format have the channel
+ * named by 'pname'?
+ */
+GLboolean
+_mesa_base_format_has_channel(GLenum base_format, GLenum pname)
+{
+ switch (pname) {
+ case GL_TEXTURE_RED_SIZE:
+ case GL_TEXTURE_RED_TYPE:
+ case GL_RENDERBUFFER_RED_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
+ if (base_format == GL_RED ||
+ base_format == GL_RG ||
+ base_format == GL_RGB ||
+ base_format == GL_RGBA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_GREEN_SIZE:
+ case GL_TEXTURE_GREEN_TYPE:
+ case GL_RENDERBUFFER_GREEN_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
+ if (base_format == GL_RG ||
+ base_format == GL_RGB ||
+ base_format == GL_RGBA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_BLUE_SIZE:
+ case GL_TEXTURE_BLUE_TYPE:
+ case GL_RENDERBUFFER_BLUE_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
+ if (base_format == GL_RGB ||
+ base_format == GL_RGBA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_ALPHA_SIZE:
+ case GL_TEXTURE_ALPHA_TYPE:
+ case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
+ if (base_format == GL_RGBA ||
+ base_format == GL_ALPHA ||
+ base_format == GL_LUMINANCE_ALPHA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_LUMINANCE_SIZE:
+ case GL_TEXTURE_LUMINANCE_TYPE:
+ if (base_format == GL_LUMINANCE ||
+ base_format == GL_LUMINANCE_ALPHA) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_INTENSITY_SIZE:
+ case GL_TEXTURE_INTENSITY_TYPE:
+ if (base_format == GL_INTENSITY) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_TEXTURE_DEPTH_SIZE:
+ case GL_TEXTURE_DEPTH_TYPE:
+ case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
+ if (base_format == GL_DEPTH_STENCIL ||
+ base_format == GL_DEPTH_COMPONENT) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
+ case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
+ if (base_format == GL_DEPTH_STENCIL ||
+ base_format == GL_STENCIL_INDEX) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+ default:
+ _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n",
+ __FUNCTION__, pname);
+ return GL_FALSE;
+ }
+
+ return GL_FALSE;
+}
+
+
+/**
* Return the address of a specific pixel in an image (1D, 2D or 3D).
*
* Pixel unpacking/packing parameters are observed according to \p packing.
diff --git a/mesalib/src/mesa/main/image.h b/mesalib/src/mesa/main/image.h
index 46adaec41..b606545b7 100644
--- a/mesalib/src/mesa/main/image.h
+++ b/mesalib/src/mesa/main/image.h
@@ -84,6 +84,9 @@ _mesa_is_integer_format(GLenum format);
extern GLboolean
_mesa_is_compressed_format(struct gl_context *ctx, GLenum format);
+extern GLboolean
+_mesa_base_format_has_channel(GLenum base_format, GLenum pname);
+
extern GLvoid *
_mesa_image_address( GLuint dimensions,
const struct gl_pixelstore_attrib *packing,
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index 461de9d1b..c621800c0 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -1825,6 +1825,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
GLint slice;
GLboolean nextLevel;
GLubyte **srcMaps, **dstMaps;
+ GLboolean success = GL_TRUE;
/* get src image parameters */
srcImage = _mesa_select_tex_image(ctx, texObj, target, level);
@@ -1873,42 +1874,74 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
}
/* Map src texture image slices */
- srcMaps = (GLubyte **) malloc(srcDepth * sizeof(GLubyte *));
- for (slice = 0; slice < srcDepth; slice++) {
- ctx->Driver.MapTextureImage(ctx, srcImage, slice,
- 0, 0, srcWidth, srcHeight,
- GL_MAP_READ_BIT,
- &srcMaps[slice], &srcRowStride);
+ srcMaps = (GLubyte **) calloc(srcDepth, sizeof(GLubyte *));
+ if (srcMaps) {
+ for (slice = 0; slice < srcDepth; slice++) {
+ ctx->Driver.MapTextureImage(ctx, srcImage, slice,
+ 0, 0, srcWidth, srcHeight,
+ GL_MAP_READ_BIT,
+ &srcMaps[slice], &srcRowStride);
+ if (!srcMaps[slice]) {
+ success = GL_FALSE;
+ break;
+ }
+ }
+ }
+ else {
+ success = GL_FALSE;
}
/* Map dst texture image slices */
- dstMaps = (GLubyte **) malloc(dstDepth * sizeof(GLubyte *));
- for (slice = 0; slice < dstDepth; slice++) {
- ctx->Driver.MapTextureImage(ctx, dstImage, slice,
- 0, 0, dstWidth, dstHeight,
- GL_MAP_WRITE_BIT,
- &dstMaps[slice], &dstRowStride);
+ dstMaps = (GLubyte **) calloc(dstDepth, sizeof(GLubyte *));
+ if (dstMaps) {
+ for (slice = 0; slice < dstDepth; slice++) {
+ ctx->Driver.MapTextureImage(ctx, dstImage, slice,
+ 0, 0, dstWidth, dstHeight,
+ GL_MAP_WRITE_BIT,
+ &dstMaps[slice], &dstRowStride);
+ if (!dstMaps[slice]) {
+ success = GL_FALSE;
+ break;
+ }
+ }
+ }
+ else {
+ success = GL_FALSE;
}
- /* generate one mipmap level (for 1D/2D/3D/array/etc texture) */
- _mesa_generate_mipmap_level(target, datatype, comps, border,
- srcWidth, srcHeight, srcDepth,
- (const GLubyte **) srcMaps, srcRowStride,
- dstWidth, dstHeight, dstDepth,
- dstMaps, dstRowStride);
+ if (success) {
+ /* generate one mipmap level (for 1D/2D/3D/array/etc texture) */
+ _mesa_generate_mipmap_level(target, datatype, comps, border,
+ srcWidth, srcHeight, srcDepth,
+ (const GLubyte **) srcMaps, srcRowStride,
+ dstWidth, dstHeight, dstDepth,
+ dstMaps, dstRowStride);
+ }
/* Unmap src image slices */
- for (slice = 0; slice < srcDepth; slice++) {
- ctx->Driver.UnmapTextureImage(ctx, srcImage, slice);
+ if (srcMaps) {
+ for (slice = 0; slice < srcDepth; slice++) {
+ if (srcMaps[slice]) {
+ ctx->Driver.UnmapTextureImage(ctx, srcImage, slice);
+ }
+ }
+ free(srcMaps);
}
- free(srcMaps);
/* Unmap dst image slices */
- for (slice = 0; slice < dstDepth; slice++) {
- ctx->Driver.UnmapTextureImage(ctx, dstImage, slice);
+ if (dstMaps) {
+ for (slice = 0; slice < dstDepth; slice++) {
+ if (dstMaps[slice]) {
+ ctx->Driver.UnmapTextureImage(ctx, dstImage, slice);
+ }
+ }
+ free(dstMaps);
}
- free(dstMaps);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "mipmap generation");
+ break;
+ }
} /* loop over mipmap levels */
}
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 96a44266c..08cd80a7f 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -110,7 +110,6 @@ typedef enum
VERT_ATTRIB_COLOR1 = 4,
VERT_ATTRIB_FOG = 5,
VERT_ATTRIB_COLOR_INDEX = 6,
- VERT_ATTRIB_POINT_SIZE = 6, /*alias*/
VERT_ATTRIB_EDGEFLAG = 7,
VERT_ATTRIB_TEX0 = 8,
VERT_ATTRIB_TEX1 = 9,
@@ -120,65 +119,93 @@ typedef enum
VERT_ATTRIB_TEX5 = 13,
VERT_ATTRIB_TEX6 = 14,
VERT_ATTRIB_TEX7 = 15,
- VERT_ATTRIB_GENERIC0 = 16,
- VERT_ATTRIB_GENERIC1 = 17,
- VERT_ATTRIB_GENERIC2 = 18,
- VERT_ATTRIB_GENERIC3 = 19,
- VERT_ATTRIB_GENERIC4 = 20,
- VERT_ATTRIB_GENERIC5 = 21,
- VERT_ATTRIB_GENERIC6 = 22,
- VERT_ATTRIB_GENERIC7 = 23,
- VERT_ATTRIB_GENERIC8 = 24,
- VERT_ATTRIB_GENERIC9 = 25,
- VERT_ATTRIB_GENERIC10 = 26,
- VERT_ATTRIB_GENERIC11 = 27,
- VERT_ATTRIB_GENERIC12 = 28,
- VERT_ATTRIB_GENERIC13 = 29,
- VERT_ATTRIB_GENERIC14 = 30,
- VERT_ATTRIB_GENERIC15 = 31,
- VERT_ATTRIB_MAX = 32
+ VERT_ATTRIB_POINT_SIZE = 16,
+ VERT_ATTRIB_GENERIC0 = 17,
+ VERT_ATTRIB_GENERIC1 = 18,
+ VERT_ATTRIB_GENERIC2 = 19,
+ VERT_ATTRIB_GENERIC3 = 20,
+ VERT_ATTRIB_GENERIC4 = 21,
+ VERT_ATTRIB_GENERIC5 = 22,
+ VERT_ATTRIB_GENERIC6 = 23,
+ VERT_ATTRIB_GENERIC7 = 24,
+ VERT_ATTRIB_GENERIC8 = 25,
+ VERT_ATTRIB_GENERIC9 = 26,
+ VERT_ATTRIB_GENERIC10 = 27,
+ VERT_ATTRIB_GENERIC11 = 28,
+ VERT_ATTRIB_GENERIC12 = 29,
+ VERT_ATTRIB_GENERIC13 = 30,
+ VERT_ATTRIB_GENERIC14 = 31,
+ VERT_ATTRIB_GENERIC15 = 32,
+ VERT_ATTRIB_MAX = 33
} gl_vert_attrib;
/**
+ * Symbolic constats to help iterating over
+ * specific blocks of vertex attributes.
+ *
+ * VERT_ATTRIB_FF
+ * includes all fixed function attributes as well as
+ * the aliased GL_NV_vertex_program shader attributes.
+ * VERT_ATTRIB_TEX
+ * include the classic texture coordinate attributes.
+ * Is a subset of VERT_ATTRIB_FF.
+ * VERT_ATTRIB_GENERIC_NV
+ * include the NV shader attributes.
+ * Is a subset of VERT_ATTRIB_FF.
+ * VERT_ATTRIB_GENERIC
+ * include the OpenGL 2.0+ GLSL generic shader attributes.
+ * These alias the generic GL_ARB_vertex_shader attributes.
+ */
+#define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i))
+#define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0
+
+#define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i))
+#define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS
+
+#define VERT_ATTRIB_GENERIC_NV(i) (VERT_ATTRIB_POS + (i))
+#define VERT_ATTRIB_GENERIC_NV_MAX MAX_VERTEX_GENERIC_ATTRIBS
+
+#define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i))
+#define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
+
+/**
* Bitflags for vertex attributes.
* These are used in bitfields in many places.
*/
/*@{*/
-#define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
-#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
-#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
-#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
-#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
-#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
-#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX)
-#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG)
-#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
-#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
-#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
-#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
-#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
-#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
-#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
-#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
-#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
-#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
-#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
-#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
-#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4)
-#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5)
-#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6)
-#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7)
-#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8)
-#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9)
-#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10)
-#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11)
-#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12)
-#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13)
-#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14)
-#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15)
-
-#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
-#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
+#define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS)
+#define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT)
+#define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL)
+#define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0)
+#define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1)
+#define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG)
+#define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX)
+#define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG)
+#define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0)
+#define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1)
+#define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2)
+#define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3)
+#define VERT_BIT_TEX4 BITFIELD64_BIT(VERT_ATTRIB_TEX4)
+#define VERT_BIT_TEX5 BITFIELD64_BIT(VERT_ATTRIB_TEX5)
+#define VERT_BIT_TEX6 BITFIELD64_BIT(VERT_ATTRIB_TEX6)
+#define VERT_BIT_TEX7 BITFIELD64_BIT(VERT_ATTRIB_TEX7)
+#define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE)
+#define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0)
+
+#define VERT_BIT(i) BITFIELD64_BIT(i)
+#define VERT_BIT_ALL (BITFIELD64_BIT(VERT_ATTRIB_MAX) - 1)
+
+#define VERT_BIT_FF(i) VERT_BIT(i)
+#define VERT_BIT_FF_ALL (BITFIELD64_BIT(VERT_ATTRIB_FF_MAX) - 1)
+#define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i))
+#define VERT_BIT_TEX_ALL \
+ ((BITFIELD64_BIT(VERT_ATTRIB_TEX_MAX) - 1) << VERT_ATTRIB_TEX(0))
+#define VERT_BIT_GENERIC_NV(i) VERT_BIT(VERT_ATTRIB_GENERIC_NV(i))
+#define VERT_BIT_GENERIC_NV_ALL \
+ ((BITFIELD64_BIT(VERT_ATTRIB_GENERIC_NV_MAX) - 1) << (VERT_ATTRIB_GENERIC_NV(0)))
+#define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
+#define VERT_BIT_GENERIC_ALL \
+ ((BITFIELD64_BIT(VERT_ATTRIB_GENERIC_MAX) - 1) << (VERT_ATTRIB_GENERIC(0)))
/*@}*/
@@ -1342,15 +1369,6 @@ struct gl_texture_object
/** GL_OES_EGL_image_external */
GLint RequiredTextureImageUnits;
-
- /**
- * \name For device driver.
- * Note: instead of attaching driver data to this pointer, it's preferable
- * to instead use this struct as a base class for your own texture object
- * class. Driver->NewTextureObject() can be used to implement the
- * allocation.
- */
- void *DriverData; /**< Arbitrary device driver data */
};
@@ -1590,36 +1608,19 @@ struct gl_array_object
_glthread_Mutex Mutex;
GLboolean VBOonly; /**< require all arrays to live in VBOs? */
- /** Conventional vertex arrays */
- /*@{*/
- struct gl_client_array Vertex;
- struct gl_client_array Weight;
- struct gl_client_array Normal;
- struct gl_client_array Color;
- struct gl_client_array SecondaryColor;
- struct gl_client_array FogCoord;
- struct gl_client_array Index;
- struct gl_client_array EdgeFlag;
- struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
- struct gl_client_array PointSize;
- /*@}*/
-
- /**
- * Generic arrays for vertex programs/shaders.
- * For NV vertex programs, these attributes alias and take priority
- * over the conventional attribs above. For ARB vertex programs and
- * GLSL vertex shaders, these attributes are separate.
- */
- struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS];
+ /** Vertex attribute arrays */
+ struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];
- /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
- GLbitfield _Enabled;
+ /** Mask of VERT_BIT_* values indicating which arrays are enabled */
+ GLbitfield64 _Enabled;
/**
* Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs
* we can determine the max legal (in bounds) glDrawElements array index.
*/
GLuint _MaxElement;
+
+ struct gl_buffer_object *ElementArrayBufferObj;
};
@@ -1645,12 +1646,11 @@ struct gl_array_attrib
GLboolean PrimitiveRestart;
GLuint RestartIndex;
- GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */
+ GLbitfield64 NewState; /**< mask of VERT_BIT_* values */
GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */
/* GL_ARB_vertex_buffer_object */
struct gl_buffer_object *ArrayBufferObj;
- struct gl_buffer_object *ElementArrayBufferObj;
};
@@ -1838,7 +1838,7 @@ struct gl_program
struct prog_instruction *Instructions;
- GLbitfield InputsRead; /**< Bitmask of which input regs are read */
+ GLbitfield64 InputsRead; /**< Bitmask of which input regs are read */
GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */
GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */
GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */
@@ -3055,39 +3055,6 @@ struct gl_matrix_stack
/**
- * \name Bits to track array state changes
- *
- * Also used to summarize array enabled.
- */
-/*@{*/
-#define _NEW_ARRAY_VERTEX VERT_BIT_POS
-#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
-#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
-#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
-#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
-#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
-#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX
-#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG
-#define _NEW_ARRAY_POINT_SIZE VERT_BIT_COLOR_INDEX /* aliased */
-#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
-#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
-#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
-#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
-#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
-#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
-#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
-#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
-#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */
-#define _NEW_ARRAY_ALL 0xffffffff
-
-
-#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
-#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
-/*@}*/
-
-
-
-/**
* \name A bunch of flags that we think might be useful to drivers.
*
* Set in the __struct gl_contextRec::_TriangleCaps bitfield.
@@ -3378,7 +3345,7 @@ struct gl_context
GLboolean ViewportInitialized; /**< has viewport size been initialized? */
- GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
+ GLbitfield64 varying_vp_inputs; /**< mask of VERT_BIT_* flags */
/** \name Derived state */
/*@{*/
diff --git a/mesalib/src/mesa/main/nvprogram.c b/mesalib/src/mesa/main/nvprogram.c
index a0e89b10f..dae11566e 100644
--- a/mesalib/src/mesa/main/nvprogram.c
+++ b/mesalib/src/mesa/main/nvprogram.c
@@ -365,7 +365,7 @@ _mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params)
return;
}
- array = &ctx->Array.ArrayObj->VertexAttrib[index];
+ array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
switch (pname) {
case GL_ATTRIB_ARRAY_SIZE_NV:
@@ -409,7 +409,7 @@ _mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params)
return;
}
- array = &ctx->Array.ArrayObj->VertexAttrib[index];
+ array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
switch (pname) {
case GL_ATTRIB_ARRAY_SIZE_NV:
@@ -453,7 +453,7 @@ _mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params)
return;
}
- array = &ctx->Array.ArrayObj->VertexAttrib[index];
+ array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
switch (pname) {
case GL_ATTRIB_ARRAY_SIZE_NV:
@@ -508,7 +508,7 @@ _mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer)
return;
}
- *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr;
+ *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr;
}
void
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index 6f48a2e7c..4754d34c6 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -2245,7 +2245,7 @@ get_component_mapping(GLenum format,
*gSrc = 0;
*rSrc = *bSrc = *aSrc = -1;
break;
- case GL_BLUE:
+ case GL_BLUE:
case GL_BLUE_INTEGER_EXT:
*bSrc = 0;
*rSrc = *gSrc = *aSrc = -1;
@@ -2291,6 +2291,7 @@ get_component_mapping(GLenum format,
*aDst = 3;
break;
case GL_BGR:
+ case GL_BGR_INTEGER:
*rSrc = 2;
*gSrc = 1;
*bSrc = 0;
@@ -2312,6 +2313,7 @@ get_component_mapping(GLenum format,
*aDst = 3;
break;
case GL_BGRA:
+ case GL_BGRA_INTEGER:
*rSrc = 2;
*gSrc = 1;
*bSrc = 0;
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index 80fd03b91..7e43563bd 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -83,98 +83,101 @@ update_arrays( struct gl_context *ctx )
struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
GLuint i, min = ~0;
- /* find min of _MaxElement values for all enabled arrays */
+ /* find min of _MaxElement values for all enabled arrays.
+ * Note that the generic arrays always take precedence over
+ * the legacy arrays.
+ */
/* 0 */
if (ctx->VertexProgram._Current
- && arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0]);
}
- else if (arrayObj->Vertex.Enabled) {
- min = update_min(min, &arrayObj->Vertex);
+ else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]);
}
/* 1 */
if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC1].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC1]);
}
/* no conventional vertex weight array */
/* 2 */
if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC2].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC2]);
}
- else if (arrayObj->Normal.Enabled) {
- min = update_min(min, &arrayObj->Normal);
+ else if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]);
}
/* 3 */
if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC3].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC3]);
}
- else if (arrayObj->Color.Enabled) {
- min = update_min(min, &arrayObj->Color);
+ else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]);
}
/* 4 */
if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC4].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC4]);
}
- else if (arrayObj->SecondaryColor.Enabled) {
- min = update_min(min, &arrayObj->SecondaryColor);
+ else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]);
}
/* 5 */
if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC5].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC5]);
}
- else if (arrayObj->FogCoord.Enabled) {
- min = update_min(min, &arrayObj->FogCoord);
+ else if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]);
}
/* 6 */
if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC6].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC6]);
}
- else if (arrayObj->Index.Enabled) {
- min = update_min(min, &arrayObj->Index);
+ else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]);
}
/* 7 */
if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC7].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC7]);
}
/* 8..15 */
- for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) {
+ for (i = 0; i < VERT_ATTRIB_TEX_MAX; i++) {
if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[i].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[i]);
+ && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC8 + i].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC8 + i]);
}
- else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits
- && arrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) {
- min = update_min(min, &arrayObj->TexCoord[i - VERT_ATTRIB_TEX0]);
+ else if (i < ctx->Const.MaxTextureCoordUnits
+ && arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]);
}
}
/* 16..31 */
if (ctx->VertexProgram._Current) {
- for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) {
- if (arrayObj->VertexAttrib[i].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[i]);
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
}
}
}
- if (arrayObj->EdgeFlag.Enabled) {
- min = update_min(min, &arrayObj->EdgeFlag);
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
+ min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]);
}
/* _MaxElement is one past the last legal array element */
@@ -589,7 +592,7 @@ _mesa_update_state_locked( struct gl_context *ctx )
if (ctx->FragmentProgram._MaintainTexEnvProgram) {
prog_flags |= (_NEW_BUFFERS | _NEW_TEXTURE | _NEW_FOG |
_NEW_ARRAY | _NEW_LIGHT | _NEW_POINT | _NEW_RENDERMODE |
- _NEW_PROGRAM | _NEW_FRAG_CLAMP);
+ _NEW_PROGRAM | _NEW_FRAG_CLAMP | _NEW_COLOR);
}
if (ctx->VertexProgram._MaintainTnlProgram) {
prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
@@ -737,7 +740,7 @@ _mesa_update_state( struct gl_context *ctx )
*/
void
_mesa_set_varying_vp_inputs( struct gl_context *ctx,
- GLbitfield varying_inputs )
+ GLbitfield64 varying_inputs )
{
if (ctx->varying_vp_inputs != varying_inputs) {
ctx->varying_vp_inputs = varying_inputs;
diff --git a/mesalib/src/mesa/main/state.h b/mesalib/src/mesa/main/state.h
index 2b5b3d514..29a254092 100644
--- a/mesalib/src/mesa/main/state.h
+++ b/mesalib/src/mesa/main/state.h
@@ -39,7 +39,7 @@ _mesa_update_state_locked(struct gl_context *ctx);
extern void
-_mesa_set_varying_vp_inputs(struct gl_context *ctx, GLbitfield varying_inputs);
+_mesa_set_varying_vp_inputs(struct gl_context *ctx, GLbitfield64 varying_inputs);
extern void
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index ee9552bc0..6d8e272ba 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -849,6 +849,15 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
}
}
+ if (ctx->Extensions.ARB_texture_rgb10_a2ui) {
+ switch (internalFormat) {
+ case GL_RGB10_A2UI:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB2101010_UINT);
+ break;
+ default:
+ break;
+ }
+ }
/* GL_BGRA can be an internal format *only* in OpenGL ES (1.x or 2.0).
*/
if (ctx->API != API_OPENGL) {
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 06506594d..ae0d51fbb 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -95,16 +95,22 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions,
0, 0, width, height, GL_MAP_READ_BIT,
&srcMap, &srcRowStride);
- for (row = 0; row < height; row++) {
- void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
- width, height, format, type,
- img, row, 0);
- const GLubyte *src = srcMap + row * srcRowStride;
- _mesa_unpack_float_z_row(texImage->TexFormat, width, src, depthRow);
- _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack);
- }
+ if (srcMap) {
+ for (row = 0; row < height; row++) {
+ void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+ width, height, format, type,
+ img, row, 0);
+ const GLubyte *src = srcMap + row * srcRowStride;
+ _mesa_unpack_float_z_row(texImage->TexFormat, width, src, depthRow);
+ _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack);
+ }
- ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
+ break;
+ }
}
free(depthRow);
@@ -133,19 +139,25 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions,
0, 0, width, height, GL_MAP_READ_BIT,
&srcMap, &rowstride);
- for (row = 0; row < height; row++) {
- const GLubyte *src = srcMap + row * rowstride;
- void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
- width, height, format, type,
- img, row, 0);
- /* XXX Z24_S8 vs. S8_Z24??? */
- memcpy(dest, src, width * sizeof(GLuint));
- if (ctx->Pack.SwapBytes) {
- _mesa_swap4((GLuint *) dest, width);
+ if (srcMap) {
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = srcMap + row * rowstride;
+ void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+ width, height, format, type,
+ img, row, 0);
+ /* XXX Z24_S8 vs. S8_Z24??? */
+ memcpy(dest, src, width * sizeof(GLuint));
+ if (ctx->Pack.SwapBytes) {
+ _mesa_swap4((GLuint *) dest, width);
+ }
}
- }
- ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
+ break;
+ }
}
}
@@ -172,27 +184,33 @@ get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions,
0, 0, width, height, GL_MAP_READ_BIT,
&srcMap, &rowstride);
- for (row = 0; row < height; row++) {
- const GLubyte *src = srcMap + row * rowstride;
- void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
- width, height, format, type,
- img, row, 0);
- memcpy(dest, src, width * sizeof(GLushort));
-
- /* check for byte swapping */
- if ((texImage->TexFormat == MESA_FORMAT_YCBCR
- && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) ||
- (texImage->TexFormat == MESA_FORMAT_YCBCR_REV
- && type == GL_UNSIGNED_SHORT_8_8_MESA)) {
- if (!ctx->Pack.SwapBytes)
+ if (srcMap) {
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = srcMap + row * rowstride;
+ void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+ width, height, format, type,
+ img, row, 0);
+ memcpy(dest, src, width * sizeof(GLushort));
+
+ /* check for byte swapping */
+ if ((texImage->TexFormat == MESA_FORMAT_YCBCR
+ && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) ||
+ (texImage->TexFormat == MESA_FORMAT_YCBCR_REV
+ && type == GL_UNSIGNED_SHORT_8_8_MESA)) {
+ if (!ctx->Pack.SwapBytes)
+ _mesa_swap2((GLushort *) dest, width);
+ }
+ else if (ctx->Pack.SwapBytes) {
_mesa_swap2((GLushort *) dest, width);
+ }
}
- else if (ctx->Pack.SwapBytes) {
- _mesa_swap2((GLushort *) dest, width);
- }
- }
- ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
+ break;
+ }
}
}
@@ -257,17 +275,22 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions,
GL_MAP_READ_BIT,
&srcMap, &srcRowStride);
- /* XXX This line is a bit of a hack to work around the
- * mismatch of compressed row strides as returned by
- * MapTextureImage() vs. what the texture decompression code
- * uses. This will be fixed in the future.
- */
- srcRowStride = srcRowStride * bh / bytes;
+ if (srcMap) {
+ /* XXX This line is a bit of a hack to work around the
+ * mismatch of compressed row strides as returned by
+ * MapTextureImage() vs. what the texture decompression code
+ * uses. This will be fixed in the future.
+ */
+ srcRowStride = srcRowStride * bh / bytes;
- _mesa_decompress_image(texFormat, width, height,
- srcMap, srcRowStride, tempImage);
+ _mesa_decompress_image(texFormat, width, height,
+ srcMap, srcRowStride, tempImage);
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
+ }
}
if (baseFormat == GL_LUMINANCE ||
@@ -314,53 +337,59 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions,
0, 0, width, height, GL_MAP_READ_BIT,
&srcMap, &rowstride);
- for (row = 0; row < height; row++) {
- const GLubyte *src = srcMap + row * rowstride;
- void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
- width, height, format, type,
- img, row, 0);
-
- _mesa_unpack_rgba_row(texFormat, width, src, rgba);
-
- if (texImage->_BaseFormat == GL_ALPHA) {
- GLint col;
- for (col = 0; col < width; col++) {
- rgba[col][RCOMP] = 0.0F;
- rgba[col][GCOMP] = 0.0F;
- rgba[col][BCOMP] = 0.0F;
+ if (srcMap) {
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = srcMap + row * rowstride;
+ void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
+ width, height, format, type,
+ img, row, 0);
+
+ _mesa_unpack_rgba_row(texFormat, width, src, rgba);
+
+ if (texImage->_BaseFormat == GL_ALPHA) {
+ GLint col;
+ for (col = 0; col < width; col++) {
+ rgba[col][RCOMP] = 0.0F;
+ rgba[col][GCOMP] = 0.0F;
+ rgba[col][BCOMP] = 0.0F;
+ }
}
- }
- else if (texImage->_BaseFormat == GL_LUMINANCE) {
- GLint col;
- for (col = 0; col < width; col++) {
- rgba[col][GCOMP] = 0.0F;
- rgba[col][BCOMP] = 0.0F;
- rgba[col][ACOMP] = 1.0F;
+ else if (texImage->_BaseFormat == GL_LUMINANCE) {
+ GLint col;
+ for (col = 0; col < width; col++) {
+ rgba[col][GCOMP] = 0.0F;
+ rgba[col][BCOMP] = 0.0F;
+ rgba[col][ACOMP] = 1.0F;
+ }
}
- }
- else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
- GLint col;
- for (col = 0; col < width; col++) {
- rgba[col][GCOMP] = 0.0F;
- rgba[col][BCOMP] = 0.0F;
+ else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
+ GLint col;
+ for (col = 0; col < width; col++) {
+ rgba[col][GCOMP] = 0.0F;
+ rgba[col][BCOMP] = 0.0F;
+ }
}
- }
- else if (texImage->_BaseFormat == GL_INTENSITY) {
- GLint col;
- for (col = 0; col < width; col++) {
- rgba[col][GCOMP] = 0.0F;
- rgba[col][BCOMP] = 0.0F;
- rgba[col][ACOMP] = 1.0F;
+ else if (texImage->_BaseFormat == GL_INTENSITY) {
+ GLint col;
+ for (col = 0; col < width; col++) {
+ rgba[col][GCOMP] = 0.0F;
+ rgba[col][BCOMP] = 0.0F;
+ rgba[col][ACOMP] = 1.0F;
+ }
}
+
+ _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
+ format, type, dest,
+ &ctx->Pack, transferOps);
}
- _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
- format, type, dest,
- &ctx->Pack, transferOps);
+ /* Unmap the src texture buffer */
+ ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
+ break;
}
-
- /* Unmap the src texture buffer */
- ctx->Driver.UnmapTextureImage(ctx, texImage, img);
}
free(rgba);
@@ -445,20 +474,25 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type,
0, 0, texImage->Width, texImage->Height,
GL_MAP_READ_BIT, &src, &srcRowStride);
- if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) {
- memcpy(dst, src, bytesPerRow * texImage->Height);
+ if (src) {
+ if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) {
+ memcpy(dst, src, bytesPerRow * texImage->Height);
+ }
+ else {
+ GLuint row;
+ for (row = 0; row < texImage->Height; row++) {
+ memcpy(dst, src, bytesPerRow);
+ dst += dstRowStride;
+ src += srcRowStride;
+ }
+ }
+
+ /* unmap src texture buffer */
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
}
else {
- GLuint row;
- for (row = 0; row < texImage->Height; row++) {
- memcpy(dst, src, bytesPerRow);
- dst += dstRowStride;
- src += srcRowStride;
- }
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
}
-
- /* unmap src texture buffer */
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
}
return memCopy;
@@ -569,27 +603,32 @@ _mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level
0, 0, texImage->Width, texImage->Height,
GL_MAP_READ_BIT, &src, &srcRowStride);
- /* no pixelstore or pixel transfer, but respect stride */
+ if (src) {
+ /* no pixelstore or pixel transfer, but respect stride */
- if (row_stride == srcRowStride) {
- const GLuint size = _mesa_format_image_size(texImage->TexFormat,
- texImage->Width,
- texImage->Height,
- texImage->Depth);
- memcpy(img, src, size);
+ if (row_stride == srcRowStride) {
+ const GLuint size = _mesa_format_image_size(texImage->TexFormat,
+ texImage->Width,
+ texImage->Height,
+ texImage->Depth);
+ memcpy(img, src, size);
+ }
+ else {
+ GLuint bw, bh;
+ _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
+ for (i = 0; i < (texImage->Height + bh - 1) / bh; i++) {
+ memcpy((GLubyte *)img + i * row_stride,
+ (GLubyte *)src + i * srcRowStride,
+ row_stride);
+ }
+ }
+
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
}
else {
- GLuint bw, bh;
- _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
- for (i = 0; i < (texImage->Height + bh - 1) / bh; i++) {
- memcpy((GLubyte *)img + i * row_stride,
- (GLubyte *)src + i * srcRowStride,
- row_stride);
- }
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetCompresssedTexImage");
}
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
-
if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj);
}
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 56335ad10..2bc7abdc2 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -331,6 +331,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
case GL_RGBA8I_EXT:
case GL_RGBA16I_EXT:
case GL_RGBA32I_EXT:
+ case GL_RGB10_A2UI:
return GL_RGBA;
case GL_RGB8UI_EXT:
case GL_RGB16UI_EXT:
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 0081c3b52..f4ec63388 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -35,6 +35,7 @@
#include "main/context.h"
#include "main/enums.h"
#include "main/formats.h"
+#include "main/image.h"
#include "main/macros.h"
#include "main/mfeatures.h"
#include "main/mtypes.h"
@@ -884,72 +885,6 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
}
-static GLboolean
-base_format_has_channel(GLenum base_format, GLenum pname)
-{
- switch (pname) {
- case GL_TEXTURE_RED_SIZE:
- case GL_TEXTURE_RED_TYPE:
- if (base_format == GL_RED ||
- base_format == GL_RG ||
- base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_GREEN_SIZE:
- case GL_TEXTURE_GREEN_TYPE:
- if (base_format == GL_RG ||
- base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_BLUE_SIZE:
- case GL_TEXTURE_BLUE_TYPE:
- if (base_format == GL_RGB ||
- base_format == GL_RGBA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_ALPHA_SIZE:
- case GL_TEXTURE_ALPHA_TYPE:
- if (base_format == GL_RGBA ||
- base_format == GL_ALPHA ||
- base_format == GL_LUMINANCE_ALPHA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_LUMINANCE_SIZE:
- case GL_TEXTURE_LUMINANCE_TYPE:
- if (base_format == GL_LUMINANCE ||
- base_format == GL_LUMINANCE_ALPHA) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_INTENSITY_SIZE:
- case GL_TEXTURE_INTENSITY_TYPE:
- if (base_format == GL_INTENSITY) {
- return GL_TRUE;
- }
- return GL_FALSE;
- case GL_TEXTURE_DEPTH_SIZE:
- case GL_TEXTURE_DEPTH_TYPE:
- if (base_format == GL_DEPTH_STENCIL ||
- base_format == GL_DEPTH_COMPONENT) {
- return GL_TRUE;
- }
- return GL_FALSE;
- default:
- _mesa_warning(NULL, "%s: Unexpected channel token 0x%x\n",
- __FUNCTION__, pname);
- return GL_FALSE;
- }
-
- return GL_FALSE;
-}
-
-
void GLAPIENTRY
_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
GLenum pname, GLfloat *params )
@@ -1048,34 +983,25 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
case GL_TEXTURE_GREEN_SIZE:
case GL_TEXTURE_BLUE_SIZE:
case GL_TEXTURE_ALPHA_SIZE:
- if (base_format_has_channel(img->_BaseFormat, pname))
+ if (_mesa_base_format_has_channel(img->_BaseFormat, pname))
*params = _mesa_get_format_bits(texFormat, pname);
else
*params = 0;
break;
case GL_TEXTURE_INTENSITY_SIZE:
- if (img->_BaseFormat != GL_INTENSITY)
- *params = 0;
- else {
+ case GL_TEXTURE_LUMINANCE_SIZE:
+ if (_mesa_base_format_has_channel(img->_BaseFormat, pname)) {
*params = _mesa_get_format_bits(texFormat, pname);
if (*params == 0) {
- /* intensity probably stored as rgb texture */
- *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE),
- _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE));
+ /* intensity or luminance is probably stored as RGB[A] */
+ *params = MIN2(_mesa_get_format_bits(texFormat,
+ GL_TEXTURE_RED_SIZE),
+ _mesa_get_format_bits(texFormat,
+ GL_TEXTURE_GREEN_SIZE));
}
}
- break;
- case GL_TEXTURE_LUMINANCE_SIZE:
- if (img->_BaseFormat != GL_LUMINANCE &&
- img->_BaseFormat != GL_LUMINANCE_ALPHA)
- *params = 0;
else {
- *params = _mesa_get_format_bits(texFormat, pname);
- if (*params == 0) {
- /* luminance probably stored as rgb texture */
- *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE),
- _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE));
- }
+ *params = 0;
}
break;
case GL_TEXTURE_DEPTH_SIZE_ARB:
@@ -1122,7 +1048,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
case GL_TEXTURE_DEPTH_TYPE_ARB:
if (!ctx->Extensions.ARB_texture_float)
goto invalid_pname;
- if (base_format_has_channel(img->_BaseFormat, pname))
+ if (_mesa_base_format_has_channel(img->_BaseFormat, pname))
*params = _mesa_get_format_datatype(texFormat);
else
*params = GL_NONE;
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 6deeb642e..007959077 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -2226,7 +2226,7 @@ _mesa_texstore_unorm88(TEXSTORE_PARAMS)
if (dstFormat == MESA_FORMAT_AL88 ||
dstFormat == MESA_FORMAT_RG88) {
for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
+ /* src[0] is luminance (or R), src[1] is alpha (or G) */
dstUS[col] = PACK_COLOR_88( src[1],
src[0] );
src += 2;
@@ -2234,7 +2234,7 @@ _mesa_texstore_unorm88(TEXSTORE_PARAMS)
}
else {
for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
+ /* src[0] is luminance (or R), src[1] is alpha (or G) */
dstUS[col] = PACK_COLOR_88_REV( src[1],
src[0] );
src += 2;
@@ -4254,6 +4254,64 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
}
static GLboolean
+_mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_ARGB2101010_UINT);
+ ASSERT(texelBytes == 4);
+
+ if (!srcPacking->SwapBytes &&
+ dstFormat == MESA_FORMAT_ARGB2101010_UINT &&
+ srcFormat == GL_BGRA_INTEGER_EXT &&
+ srcType == GL_UNSIGNED_INT_2_10_10_10_REV &&
+ baseInternalFormat == GL_RGBA) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLuint *tempImage = make_temp_uint_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight,
+ srcDepth, srcFormat,
+ srcType, srcAddr,
+ srcPacking);
+ const GLuint *src = tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ GLushort a,r,g,b;
+ r = src[RCOMP];
+ g = src[GCOMP];
+ b = src[BCOMP];
+ a = src[ACOMP];
+ dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b);
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+static GLboolean
_mesa_texstore_null(TEXSTORE_PARAMS)
{
(void) ctx; (void) dims;
@@ -4446,6 +4504,7 @@ _mesa_get_texstore_func(gl_format format)
table[MESA_FORMAT_RGB_UINT32] = _mesa_texstore_rgba_uint32;
table[MESA_FORMAT_RGBA_UINT32] = _mesa_texstore_rgba_uint32;
+ table[MESA_FORMAT_ARGB2101010_UINT] = _mesa_texstore_argb2101010_uint;
initialized = GL_TRUE;
}
@@ -4537,16 +4596,20 @@ _mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level,
0, 0, width, 1,
rwMode,
&dstMap, &dstRowStride);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ 0, /* dstRowStride */
+ &dstMap,
+ width, 1, 1,
+ format, type, pixels, packing);
- success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- 0, /* dstRowStride */
- &dstMap,
- width, 1, 1,
- format, type, pixels, packing);
-
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ success = GL_FALSE;
+ }
if (!success)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
@@ -4609,15 +4672,19 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
0, 0, width, 1,
rwMode,
&dstMap, &dstRowStride);
- assert(dstMap);
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, 1, 1,
- format, type, pixels, packing);
- ctx->Driver.UnmapTextureImage(ctx, texImage, y);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, 1, 1,
+ format, type, pixels, packing);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, y);
+ }
+ else {
+ success = GL_FALSE;
+ }
if (!success)
break;
@@ -4630,16 +4697,20 @@ _mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level,
0, 0, width, height,
rwMode,
&dstMap, &dstRowStride);
- assert(dstMap);
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, height, 1,
- format, type, pixels, packing);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, height, 1,
+ format, type, pixels, packing);
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ success = GL_FALSE;
+ }
}
if (!success)
@@ -4664,7 +4735,7 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- GLboolean success;
+ GLboolean success = GL_TRUE;
GLint slice;
GLubyte **sliceMaps;
GLint dstRowStride;
@@ -4696,7 +4767,7 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
height = 1;
}
- sliceMaps = (GLubyte **) malloc(depth * sizeof(GLubyte *));
+ sliceMaps = (GLubyte **) calloc(depth, sizeof(GLubyte *));
/* Map dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
@@ -4704,19 +4775,27 @@ _mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level,
0, 0, width, height,
rwMode,
&sliceMaps[slice], &dstRowStride);
+ if (!sliceMaps[slice]) {
+ success = GL_FALSE;
+ break;
+ }
}
- success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- sliceMaps,
- width, height, depth,
- format, type, pixels, packing);
+ if (success) {
+ success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ sliceMaps,
+ width, height, depth,
+ format, type, pixels, packing);
+ }
/* Unmap dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
- ctx->Driver.UnmapTextureImage(ctx, texImage, slice);
+ if (sliceMaps[slice]) {
+ ctx->Driver.UnmapTextureImage(ctx, texImage, slice);
+ }
}
if (!success)
@@ -4759,15 +4838,20 @@ _mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level,
rwMode,
&dstMap, &dstRowStride);
- success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, 1, 1,
- format, type, pixels, packing);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, 1, 1,
+ format, type, pixels, packing);
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ success = GL_FALSE;
+ }
if (!success)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
@@ -4807,15 +4891,20 @@ _mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level,
rwMode,
&dstMap, &dstRowStride);
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, height, 1,
- format, type, pixels, packing);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, height, 1,
+ format, type, pixels, packing);
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ success = GL_FALSE;
+ }
if (!success)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
@@ -4838,7 +4927,7 @@ _mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- GLboolean success;
+ GLboolean success = GL_TRUE;
GLint slice;
GLubyte **sliceMaps;
GLint dstRowStride;
@@ -4850,7 +4939,7 @@ _mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
if (!pixels)
return;
- sliceMaps = (GLubyte **) malloc(depth * sizeof(GLubyte *));
+ sliceMaps = (GLubyte **) calloc(depth, sizeof(GLubyte *));
/* Map dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
@@ -4858,19 +4947,27 @@ _mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level,
xoffset, yoffset, width, height,
rwMode,
&sliceMaps[slice], &dstRowStride);
+ if (!sliceMaps[slice]) {
+ success = GL_FALSE;
+ break;
+ }
}
- success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0,
- dstRowStride,
- sliceMaps,
- width, height, depth,
- format, type, pixels, packing);
+ if (success) {
+ success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0,
+ dstRowStride,
+ sliceMaps,
+ width, height, depth,
+ format, type, pixels, packing);
+ }
/* Unmap dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
- ctx->Driver.UnmapTextureImage(ctx, texImage, zoffset + slice);
+ if (sliceMaps[slice]) {
+ ctx->Driver.UnmapTextureImage(ctx, texImage, zoffset + slice);
+ }
}
if (!success)
@@ -4949,11 +5046,15 @@ _mesa_store_compressed_teximage2d(struct gl_context *ctx,
0, 0, width, height,
GL_MAP_WRITE_BIT,
&dstMap, &dstRowStride);
+ if (dstMap) {
+ /* copy the data */
+ memcpy(dstMap, data, imageSize);
- /* copy the data */
- memcpy(dstMap, data, imageSize);
-
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ }
_mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
}
@@ -5053,17 +5154,22 @@ _mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target,
GL_MAP_WRITE_BIT,
&dstMap, &dstRowStride);
- bytesPerRow = srcRowStride; /* bytes per row of blocks */
- rows = height / bh; /* rows in blocks */
+ if (dstMap) {
+ bytesPerRow = srcRowStride; /* bytes per row of blocks */
+ rows = height / bh; /* rows in blocks */
- /* copy rows of blocks */
- for (i = 0; i < rows; i++) {
- memcpy(dstMap, src, bytesPerRow);
- dstMap += dstRowStride;
- src += srcRowStride;
- }
+ /* copy rows of blocks */
+ for (i = 0; i < rows; i++) {
+ memcpy(dstMap, src, bytesPerRow);
+ dstMap += dstRowStride;
+ src += srcRowStride;
+ }
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");
+ }
_mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
}
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index f1a57c1f0..cfb0aa2a0 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -108,8 +108,7 @@ type_to_bit(const struct gl_context *ctx, GLenum type)
* functions.
*
* \param func name of calling function used for error reporting
- * \param array the array to update
- * \param dirtyBit which bit to set in ctx->Array.NewState for this array
+ * \param attrib the attribute array index to update
* \param legalTypes bitmask of *_BIT above indicating legal datatypes
* \param sizeMin min allowable size value
* \param sizeMax max allowable size value (may also be BGRA_OR_4)
@@ -123,13 +122,13 @@ type_to_bit(const struct gl_context *ctx, GLenum type)
static void
update_array(struct gl_context *ctx,
const char *func,
- struct gl_client_array *array,
- GLbitfield dirtyBit, GLbitfield legalTypesMask,
+ GLuint attrib, GLbitfield legalTypesMask,
GLint sizeMin, GLint sizeMax,
GLint size, GLenum type, GLsizei stride,
GLboolean normalized, GLboolean integer,
const GLvoid *ptr)
{
+ struct gl_client_array *array;
GLbitfield typeBit;
GLsizei elementSize;
GLenum format = GL_RGBA;
@@ -206,6 +205,7 @@ update_array(struct gl_context *ctx,
elementSize = _mesa_sizeof_type(type) * size;
+ array = &ctx->Array.ArrayObj->VertexAttrib[attrib];
array->Size = size;
array->Type = type;
array->Format = format;
@@ -220,7 +220,7 @@ update_array(struct gl_context *ctx,
ctx->Array.ArrayBufferObj);
ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= dirtyBit;
+ ctx->Array.NewState |= VERT_BIT(attrib);
}
@@ -237,8 +237,7 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
if (ctx->API == API_OPENGLES)
legalTypes |= BYTE_BIT;
- update_array(ctx, "glVertexPointer",
- &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
+ update_array(ctx, "glVertexPointer", VERT_ATTRIB_POS,
legalTypes, 2, 4,
size, type, stride, GL_FALSE, GL_FALSE, ptr);
}
@@ -255,8 +254,7 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- update_array(ctx, "glNormalPointer",
- &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
+ update_array(ctx, "glNormalPointer", VERT_ATTRIB_NORMAL,
legalTypes, 3, 3,
3, type, stride, GL_TRUE, GL_FALSE, ptr);
}
@@ -275,8 +273,7 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- update_array(ctx, "glColorPointer",
- &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
+ update_array(ctx, "glColorPointer", VERT_ATTRIB_COLOR0,
legalTypes, 3, BGRA_OR_4,
size, type, stride, GL_TRUE, GL_FALSE, ptr);
}
@@ -289,8 +286,7 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- update_array(ctx, "glFogCoordPointer",
- &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
+ update_array(ctx, "glFogCoordPointer", VERT_ATTRIB_FOG,
legalTypes, 1, 1,
1, type, stride, GL_FALSE, GL_FALSE, ptr);
}
@@ -304,8 +300,7 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- update_array(ctx, "glIndexPointer",
- &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
+ update_array(ctx, "glIndexPointer", VERT_ATTRIB_COLOR_INDEX,
legalTypes, 1, 1,
1, type, stride, GL_FALSE, GL_FALSE, ptr);
}
@@ -324,8 +319,7 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- update_array(ctx, "glSecondaryColorPointer",
- &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1,
+ update_array(ctx, "glSecondaryColorPointer", VERT_ATTRIB_COLOR1,
legalTypes, 3, BGRA_OR_4,
size, type, stride, GL_TRUE, GL_FALSE, ptr);
}
@@ -347,11 +341,7 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
if (ctx->API == API_OPENGLES)
legalTypes |= BYTE_BIT;
- ASSERT(unit < Elements(ctx->Array.ArrayObj->TexCoord));
-
- update_array(ctx, "glTexCoordPointer",
- &ctx->Array.ArrayObj->TexCoord[unit],
- _NEW_ARRAY_TEXCOORD(unit),
+ update_array(ctx, "glTexCoordPointer", VERT_ATTRIB_TEX(unit),
legalTypes, 1, 4,
size, type, stride, GL_FALSE, GL_FALSE,
ptr);
@@ -367,8 +357,7 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- update_array(ctx, "glEdgeFlagPointer",
- &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
+ update_array(ctx, "glEdgeFlagPointer", VERT_ATTRIB_EDGEFLAG,
legalTypes, 1, 1,
1, GL_UNSIGNED_BYTE, stride, GL_FALSE, integer, ptr);
}
@@ -387,8 +376,7 @@ _mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr)
return;
}
- update_array(ctx, "glPointSizePointer",
- &ctx->Array.ArrayObj->PointSize, _NEW_ARRAY_POINT_SIZE,
+ update_array(ctx, "glPointSizePointer", VERT_ATTRIB_POINT_SIZE,
legalTypes, 1, 1,
1, type, stride, GL_FALSE, GL_FALSE, ptr);
}
@@ -421,9 +409,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
return;
}
- update_array(ctx, "glVertexAttribPointerNV",
- &ctx->Array.ArrayObj->VertexAttrib[index],
- _NEW_ARRAY_ATTRIB(index),
+ update_array(ctx, "glVertexAttribPointerNV", VERT_ATTRIB_GENERIC(index),
legalTypes, 1, BGRA_OR_4,
size, type, stride, normalized, GL_FALSE, ptr);
}
@@ -456,9 +442,7 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
return;
}
- update_array(ctx, "glVertexAttribPointer",
- &ctx->Array.ArrayObj->VertexAttrib[index],
- _NEW_ARRAY_ATTRIB(index),
+ update_array(ctx, "glVertexAttribPointer", VERT_ATTRIB_GENERIC(index),
legalTypes, 1, BGRA_OR_4,
size, type, stride, normalized, GL_FALSE, ptr);
}
@@ -488,9 +472,7 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
return;
}
- update_array(ctx, "glVertexAttribIPointer",
- &ctx->Array.ArrayObj->VertexAttrib[index],
- _NEW_ARRAY_ATTRIB(index),
+ update_array(ctx, "glVertexAttribIPointer", VERT_ATTRIB_GENERIC(index),
legalTypes, 1, 4,
size, type, stride, normalized, integer, ptr);
}
@@ -509,12 +491,12 @@ _mesa_EnableVertexAttribArrayARB(GLuint index)
return;
}
- ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
FLUSH_VERTICES(ctx, _NEW_ARRAY);
- ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_TRUE;
- ctx->Array.ArrayObj->_Enabled |= _NEW_ARRAY_ATTRIB(index);
- ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
+ ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
+ ctx->Array.ArrayObj->_Enabled |= VERT_BIT_GENERIC(index);
+ ctx->Array.NewState |= VERT_BIT_GENERIC(index);
}
@@ -530,12 +512,12 @@ _mesa_DisableVertexAttribArrayARB(GLuint index)
return;
}
- ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
FLUSH_VERTICES(ctx, _NEW_ARRAY);
- ctx->Array.ArrayObj->VertexAttrib[index].Enabled = GL_FALSE;
- ctx->Array.ArrayObj->_Enabled &= ~_NEW_ARRAY_ATTRIB(index);
- ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
+ ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
+ ctx->Array.ArrayObj->_Enabled &= ~VERT_BIT_GENERIC(index);
+ ctx->Array.NewState |= VERT_BIT_GENERIC(index);
}
@@ -555,9 +537,9 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
return 0;
}
- ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
- array = &ctx->Array.ArrayObj->VertexAttrib[index];
+ array = &ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
switch (pname) {
case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
@@ -607,8 +589,10 @@ get_current_attrib(struct gl_context *ctx, GLuint index, const char *function)
return NULL;
}
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
FLUSH_CURRENT(ctx, 0);
- return ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index];
+ return ctx->Current.Attrib[VERT_ATTRIB_GENERIC(index)];
}
void GLAPIENTRY
@@ -741,9 +725,9 @@ _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
return;
}
- ASSERT(index < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
- *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr;
+ *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr;
}
@@ -1004,7 +988,7 @@ _mesa_LockArraysEXT(GLint first, GLsizei count)
ctx->Array.LockCount = count;
ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_ALL;
+ ctx->Array.NewState |= VERT_BIT_ALL;
}
@@ -1025,7 +1009,7 @@ _mesa_UnlockArraysEXT( void )
ctx->Array.LockFirst = 0;
ctx->Array.LockCount = 0;
ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_ALL;
+ ctx->Array.NewState |= VERT_BIT_ALL;
}
@@ -1133,7 +1117,9 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
return;
}
- ctx->Array.ArrayObj->VertexAttrib[index].InstanceDivisor = divisor;
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
+
+ ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].InstanceDivisor = divisor;
}
@@ -1193,18 +1179,18 @@ _mesa_print_arrays(struct gl_context *ctx)
_mesa_update_array_object_max_element(ctx, arrayObj);
printf("Array Object %u\n", arrayObj->Name);
- if (arrayObj->Vertex.Enabled)
- print_array("Vertex", -1, &arrayObj->Vertex);
- if (arrayObj->Normal.Enabled)
- print_array("Normal", -1, &arrayObj->Normal);
- if (arrayObj->Color.Enabled)
- print_array("Color", -1, &arrayObj->Color);
- for (i = 0; i < Elements(arrayObj->TexCoord); i++)
- if (arrayObj->TexCoord[i].Enabled)
- print_array("TexCoord", i, &arrayObj->TexCoord[i]);
- for (i = 0; i < Elements(arrayObj->VertexAttrib); i++)
- if (arrayObj->VertexAttrib[i].Enabled)
- print_array("Attrib", i, &arrayObj->VertexAttrib[i]);
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled)
+ print_array("Vertex", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]);
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled)
+ print_array("Normal", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]);
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled)
+ print_array("Color", -1, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]);
+ for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled)
+ print_array("TexCoord", i, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]);
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++)
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
+ print_array("Attrib", i, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
printf(" _MaxElement = %u\n", arrayObj->_MaxElement);
}