aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa')
-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
-rw-r--r--mesalib/src/mesa/program/program_parse.y6
-rw-r--r--mesalib/src/mesa/program/programopt.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_pixeltransfer.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp8
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c10
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c7
-rw-r--r--mesalib/src/mesa/tnl/t_vb_program.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_attrib.h59
-rw-r--r--mesalib/src/mesa/vbo/vbo_context.c494
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec.h4
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_api.c24
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c128
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_draw.c24
-rw-r--r--mesalib/src/mesa/vbo/vbo_save.c254
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c4
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_draw.c18
50 files changed, 1505 insertions, 1361 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);
}
diff --git a/mesalib/src/mesa/program/program_parse.y b/mesalib/src/mesa/program/program_parse.y
index dec35038b..9fdb99db3 100644
--- a/mesalib/src/mesa/program/program_parse.y
+++ b/mesalib/src/mesa/program/program_parse.y
@@ -802,7 +802,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
break;
case at_attrib:
set_src_reg(& $$, PROGRAM_INPUT, s->attrib_binding);
- state->prog->InputsRead |= (1U << $$.Base.Index);
+ state->prog->InputsRead |= BITFIELD64_BIT($$.Base.Index);
if (!validate_inputs(& @1, state)) {
YYERROR;
@@ -817,7 +817,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
| attribBinding
{
set_src_reg(& $$, PROGRAM_INPUT, $1);
- state->prog->InputsRead |= (1U << $$.Base.Index);
+ state->prog->InputsRead |= BITFIELD64_BIT($$.Base.Index);
if (!validate_inputs(& @1, state)) {
YYERROR;
@@ -2768,7 +2768,7 @@ _mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *st
state->prog->NumInstructions++;
state->prog->NumParameters = state->prog->Parameters->NumParameters;
- state->prog->NumAttributes = _mesa_bitcount(state->prog->InputsRead);
+ state->prog->NumAttributes = _mesa_bitcount_64(state->prog->InputsRead);
/*
* Initialize native counts to logical counts. The device driver may
diff --git a/mesalib/src/mesa/program/programopt.c b/mesalib/src/mesa/program/programopt.c
index c72dfb23b..389ea218b 100644
--- a/mesalib/src/mesa/program/programopt.c
+++ b/mesalib/src/mesa/program/programopt.c
@@ -631,7 +631,7 @@ _mesa_nop_fragment_program(struct gl_context *ctx, struct gl_fragment_program *p
prog->Base.Instructions = inst;
prog->Base.NumInstructions = 2;
- prog->Base.InputsRead = 1 << inputAttr;
+ prog->Base.InputsRead = BITFIELD64_BIT(inputAttr);
prog->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR);
}
@@ -675,7 +675,7 @@ _mesa_nop_vertex_program(struct gl_context *ctx, struct gl_vertex_program *prog)
prog->Base.Instructions = inst;
prog->Base.NumInstructions = 2;
- prog->Base.InputsRead = 1 << inputAttr;
+ prog->Base.InputsRead = BITFIELD64_BIT(inputAttr);
prog->Base.OutputsWritten = BITFIELD64_BIT(VERT_RESULT_COL0);
/*
diff --git a/mesalib/src/mesa/state_tracker/st_atom_pixeltransfer.c b/mesalib/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 12b5bc5ba..afca60976 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -166,7 +166,7 @@ get_pixel_transfer_program(struct gl_context *ctx, const struct state_key *key)
inst[ic].TexSrcUnit = 0;
inst[ic].TexSrcTarget = TEXTURE_2D_INDEX;
ic++;
- fp->Base.InputsRead = (1 << FRAG_ATTRIB_TEX0);
+ fp->Base.InputsRead = BITFIELD64_BIT(FRAG_ATTRIB_TEX0);
fp->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR);
fp->Base.SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 1e8ec0556..2a60ed4df 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -124,6 +124,11 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
pipe_surface_reference( &strb->surface, NULL );
pipe_resource_reference( &strb->texture, NULL );
+ if (width == 0 || height == 0) {
+ /* if size is zero, nothing to allocate */
+ return GL_TRUE;
+ }
+
/* Setup new texture template.
*/
memset(&template, 0, sizeof(template));
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index 05a71d35c..fd1c8ee48 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -325,7 +325,7 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
if (abs(array->Ptr - firstPtr) > firstStride)
return GL_FALSE; /* arrays start too far apart */
- if ((!bufObj || !_mesa_is_bufferobj(bufObj)) != userSpaceBuffer)
+ if ((!_mesa_is_bufferobj(bufObj)) != userSpaceBuffer)
return GL_FALSE; /* mix of VBO and user-space arrays */
}
}
@@ -390,7 +390,7 @@ setup_interleaved_attribs(struct gl_context *ctx,
}
/* are the arrays in user space? */
- usingVBO = bufobj && _mesa_is_bufferobj(bufobj);
+ usingVBO = _mesa_is_bufferobj(bufobj);
for (attr = 0; attr < vpv->num_inputs; attr++) {
const GLuint mesaAttr = vp->index_to_input[attr];
@@ -497,7 +497,7 @@ setup_non_interleaved_attribs(struct gl_context *ctx,
assert(element_size == array->Size * _mesa_sizeof_type(array->Type));
- if (bufobj && _mesa_is_bufferobj(bufobj)) {
+ if (_mesa_is_bufferobj(bufobj)) {
/* Attribute data is in a VBO.
* Recall that for VBOs, the gl_client_array->Ptr field is
* really an offset from the start of the VBO, not a pointer.
@@ -599,7 +599,7 @@ setup_index_buffer(struct gl_context *ctx,
}
/* get/create the index buffer object */
- if (bufobj && _mesa_is_bufferobj(bufobj)) {
+ if (_mesa_is_bufferobj(bufobj)) {
/* elements/indexes are in a real VBO */
struct st_buffer_object *stobj = st_buffer_object(bufobj);
pipe_resource_reference(&ibuffer->buffer, stobj->buffer);
@@ -775,7 +775,7 @@ handle_fallback_primitive_restart(struct pipe_context *pipe,
info.primitive_restart = FALSE;
info.instance_count = 1;
- if (ib->obj && _mesa_is_bufferobj(ib->obj)) {
+ if (_mesa_is_bufferobj(ib->obj)) {
ptr = pipe_buffer_map_range(pipe, ibuffer->buffer,
start * ibuffer->index_size, /* start */
count * ibuffer->index_size, /* length */
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 25a6cdc75..c741d13f4 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -664,4 +664,10 @@ void st_init_extensions(struct st_context *st)
PIPE_BIND_SAMPLER_VIEW)) {
ctx->Extensions.ARB_depth_buffer_float = GL_TRUE;
}
+
+ if (screen->is_format_supported(screen, PIPE_FORMAT_B10G10R10A2_UINT,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_SAMPLER_VIEW))
+ ctx->Extensions.ARB_texture_rgb10_a2ui = GL_TRUE;
+
}
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index b11245beb..bc414f442 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -457,7 +457,8 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
return PIPE_FORMAT_R9G9B9E5_FLOAT;
case MESA_FORMAT_R11_G11_B10_FLOAT:
return PIPE_FORMAT_R11G11B10_FLOAT;
-
+ case MESA_FORMAT_ARGB2101010_UINT:
+ return PIPE_FORMAT_B10G10R10A2_UINT;
default:
assert(0);
return PIPE_FORMAT_NONE;
@@ -782,6 +783,8 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
case PIPE_FORMAT_R11G11B10_FLOAT:
return MESA_FORMAT_R11_G11_B10_FLOAT;
+ case PIPE_FORMAT_B10G10R10A2_UINT:
+ return MESA_FORMAT_ARGB2101010_UINT;
default:
assert(0);
return MESA_FORMAT_NONE;
@@ -1471,7 +1474,11 @@ static const struct format_mapping format_map[] = {
{
{ GL_R11F_G11F_B10F, 0 },
{ PIPE_FORMAT_R11G11B10_FLOAT, 0 }
- }
+ },
+ {
+ { GL_RGB10_A2UI, 0 },
+ { PIPE_FORMAT_B10G10R10A2_UINT, 0 }
+ },
};
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 74b8fa7c7..59b5ffd4c 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3731,7 +3731,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
inst->sampler = 0;
inst->tex_target = TEXTURE_2D_INDEX;
- prog->InputsRead |= (1 << FRAG_ATTRIB_TEX0);
+ prog->InputsRead |= FRAG_BIT_TEX0;
prog->SamplersUsed |= (1 << 0); /* mark sampler 0 as used */
v->samplers_used |= (1 << 0);
@@ -3802,7 +3802,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
src_regs[i].index = src0.index;
}
else if (src_regs[i].file == PROGRAM_INPUT)
- prog->InputsRead |= (1 << src_regs[i].index);
+ prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
}
v->emit(NULL, inst->op, inst->dst, src_regs[0], src_regs[1], src_regs[2]);
@@ -3855,7 +3855,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
inst->sampler = samplerIndex;
inst->tex_target = TEXTURE_2D_INDEX;
- prog->InputsRead |= (1 << FRAG_ATTRIB_TEX0);
+ prog->InputsRead |= FRAG_BIT_TEX0;
prog->SamplersUsed |= (1 << samplerIndex); /* mark sampler as used */
v->samplers_used |= (1 << samplerIndex);
@@ -3877,7 +3877,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
for (int i=0; i<3; i++) {
src_regs[i] = inst->src[i];
if (src_regs[i].file == PROGRAM_INPUT)
- prog->InputsRead |= (1 << src_regs[i].index);
+ prog->InputsRead |= BITFIELD64_BIT(src_regs[i].index);
}
v->emit(NULL, inst->op, inst->dst, src_regs[0], src_regs[1], src_regs[2]);
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index e03157940..768da5114 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -194,7 +194,7 @@ st_prepare_vertex_program(struct gl_context *ctx,
* and TGSI generic input indexes, plus input attrib semantic info.
*/
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if (stvp->Base.Base.InputsRead & (1 << attr)) {
+ if ((stvp->Base.Base.InputsRead & BITFIELD64_BIT(attr)) != 0) {
stvp->input_to_index[attr] = stvp->num_inputs;
stvp->index_to_input[stvp->num_inputs] = attr;
stvp->num_inputs++;
@@ -490,7 +490,7 @@ st_translate_fragment_program(struct st_context *st,
GLuint inputMapping[FRAG_ATTRIB_MAX];
GLuint interpMode[PIPE_MAX_SHADER_INPUTS]; /* XXX size? */
GLuint attr;
- const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
+ const GLbitfield64 inputsRead = stfp->Base.Base.InputsRead;
struct ureg_program *ureg;
GLboolean write_all = GL_FALSE;
@@ -510,7 +510,7 @@ st_translate_fragment_program(struct st_context *st,
* Convert Mesa program inputs to TGSI input register semantics.
*/
for (attr = 0; attr < FRAG_ATTRIB_MAX; attr++) {
- if (inputsRead & (1 << attr)) {
+ if ((inputsRead & BITFIELD64_BIT(attr)) != 0) {
const GLuint slot = fs_num_inputs++;
inputMapping[attr] = slot;
@@ -749,7 +749,7 @@ st_translate_geometry_program(struct st_context *st,
GLuint outputMapping[GEOM_RESULT_MAX];
struct pipe_context *pipe = st->pipe;
GLuint attr;
- const GLbitfield inputsRead = stgp->Base.Base.InputsRead;
+ const GLbitfield64 inputsRead = stgp->Base.Base.InputsRead;
GLuint vslot = 0;
GLuint num_generic = 0;
@@ -790,7 +790,7 @@ st_translate_geometry_program(struct st_context *st,
* Convert Mesa program inputs to TGSI input register semantics.
*/
for (attr = 0; attr < GEOM_ATTRIB_MAX; attr++) {
- if (inputsRead & (1 << attr)) {
+ if ((inputsRead & BITFIELD64_BIT(attr)) != 0) {
const GLuint slot = gs_num_inputs;
gs_num_inputs++;
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index bfa7da79d..bcd63b602 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -1260,6 +1260,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
fetch_texel_2d_z32f_x24s8,
fetch_texel_3d_z32f_x24s8,
store_texel_z32f_x24s8
+ },
+ {
+ MESA_FORMAT_ARGB2101010_UINT,
+ NULL,
+ NULL,
+ NULL,
+ NULL
}
};
diff --git a/mesalib/src/mesa/tnl/t_vb_program.c b/mesalib/src/mesa/tnl/t_vb_program.c
index 836e8e8fa..8b060ff93 100644
--- a/mesalib/src/mesa/tnl/t_vb_program.c
+++ b/mesalib/src/mesa/tnl/t_vb_program.c
@@ -379,7 +379,7 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage )
/* the vertex array case */
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if (program->Base.InputsRead & (1 << attr)) {
+ if (program->Base.InputsRead & BITFIELD64_BIT(attr)) {
const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data;
const GLuint size = VB->AttribPtr[attr]->size;
const GLuint stride = VB->AttribPtr[attr]->stride;
diff --git a/mesalib/src/mesa/vbo/vbo_attrib.h b/mesalib/src/mesa/vbo/vbo_attrib.h
index 0ae928f2a..c2f4e6ec8 100644
--- a/mesalib/src/mesa/vbo/vbo_attrib.h
+++ b/mesalib/src/mesa/vbo/vbo_attrib.h
@@ -60,43 +60,44 @@ enum {
VBO_ATTRIB_TEX5 = 13,
VBO_ATTRIB_TEX6 = 14,
VBO_ATTRIB_TEX7 = 15,
+ VBO_ATTRIB_POINT_SIZE = 16,
- VBO_ATTRIB_GENERIC0 = 16, /* Not used? */
- VBO_ATTRIB_GENERIC1 = 17,
- VBO_ATTRIB_GENERIC2 = 18,
- VBO_ATTRIB_GENERIC3 = 19,
- VBO_ATTRIB_GENERIC4 = 20,
- VBO_ATTRIB_GENERIC5 = 21,
- VBO_ATTRIB_GENERIC6 = 22,
- VBO_ATTRIB_GENERIC7 = 23,
- VBO_ATTRIB_GENERIC8 = 24,
- VBO_ATTRIB_GENERIC9 = 25,
- VBO_ATTRIB_GENERIC10 = 26,
- VBO_ATTRIB_GENERIC11 = 27,
- VBO_ATTRIB_GENERIC12 = 28,
- VBO_ATTRIB_GENERIC13 = 29,
- VBO_ATTRIB_GENERIC14 = 30,
- VBO_ATTRIB_GENERIC15 = 31,
+ VBO_ATTRIB_GENERIC0 = 17, /* Not used? */
+ VBO_ATTRIB_GENERIC1 = 18,
+ VBO_ATTRIB_GENERIC2 = 19,
+ VBO_ATTRIB_GENERIC3 = 20,
+ VBO_ATTRIB_GENERIC4 = 21,
+ VBO_ATTRIB_GENERIC5 = 22,
+ VBO_ATTRIB_GENERIC6 = 23,
+ VBO_ATTRIB_GENERIC7 = 24,
+ VBO_ATTRIB_GENERIC8 = 25,
+ VBO_ATTRIB_GENERIC9 = 26,
+ VBO_ATTRIB_GENERIC10 = 27,
+ VBO_ATTRIB_GENERIC11 = 28,
+ VBO_ATTRIB_GENERIC12 = 29,
+ VBO_ATTRIB_GENERIC13 = 30,
+ VBO_ATTRIB_GENERIC14 = 31,
+ VBO_ATTRIB_GENERIC15 = 32,
/* XXX: in the vertex program InputsRead flag, we alias
* materials and generics and use knowledge about the program
* (whether it is a fixed-function emulation) to
* differentiate. Here we must keep them apart instead.
*/
- VBO_ATTRIB_MAT_FRONT_AMBIENT = 32,
- VBO_ATTRIB_MAT_BACK_AMBIENT = 33,
- VBO_ATTRIB_MAT_FRONT_DIFFUSE = 34,
- VBO_ATTRIB_MAT_BACK_DIFFUSE = 35,
- VBO_ATTRIB_MAT_FRONT_SPECULAR = 36,
- VBO_ATTRIB_MAT_BACK_SPECULAR = 37,
- VBO_ATTRIB_MAT_FRONT_EMISSION = 38,
- VBO_ATTRIB_MAT_BACK_EMISSION = 39,
- VBO_ATTRIB_MAT_FRONT_SHININESS = 40,
- VBO_ATTRIB_MAT_BACK_SHININESS = 41,
- VBO_ATTRIB_MAT_FRONT_INDEXES = 42,
- VBO_ATTRIB_MAT_BACK_INDEXES = 43,
+ VBO_ATTRIB_MAT_FRONT_AMBIENT = 33,
+ VBO_ATTRIB_MAT_BACK_AMBIENT = 34,
+ VBO_ATTRIB_MAT_FRONT_DIFFUSE = 35,
+ VBO_ATTRIB_MAT_BACK_DIFFUSE = 36,
+ VBO_ATTRIB_MAT_FRONT_SPECULAR = 37,
+ VBO_ATTRIB_MAT_BACK_SPECULAR = 38,
+ VBO_ATTRIB_MAT_FRONT_EMISSION = 39,
+ VBO_ATTRIB_MAT_BACK_EMISSION = 40,
+ VBO_ATTRIB_MAT_FRONT_SHININESS = 41,
+ VBO_ATTRIB_MAT_BACK_SHININESS = 42,
+ VBO_ATTRIB_MAT_FRONT_INDEXES = 43,
+ VBO_ATTRIB_MAT_BACK_INDEXES = 44,
- VBO_ATTRIB_MAX = 44
+ VBO_ATTRIB_MAX = 45
};
#define VBO_ATTRIB_FIRST_MATERIAL VBO_ATTRIB_MAT_FRONT_AMBIENT
diff --git a/mesalib/src/mesa/vbo/vbo_context.c b/mesalib/src/mesa/vbo/vbo_context.c
index 5f03ce547..b2e6bbc12 100644
--- a/mesalib/src/mesa/vbo/vbo_context.c
+++ b/mesalib/src/mesa/vbo/vbo_context.c
@@ -1,249 +1,245 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "main/imports.h"
-#include "main/mtypes.h"
-#include "main/api_arrayelt.h"
-#include "main/bufferobj.h"
-#include "math/m_eval.h"
-#include "vbo.h"
-#include "vbo_context.h"
-
-
-
-#define NR_LEGACY_ATTRIBS 16
-#define NR_GENERIC_ATTRIBS 16
-#define NR_MAT_ATTRIBS 12
-
-
-static GLuint check_size( const GLfloat *attr )
-{
- if (attr[3] != 1.0) return 4;
- if (attr[2] != 0.0) return 3;
- if (attr[1] != 0.0) return 2;
- return 1;
-}
-
-
-static void init_legacy_currval(struct gl_context *ctx)
-{
- struct vbo_context *vbo = vbo_context(ctx);
- struct gl_client_array *arrays = vbo->legacy_currval;
- GLuint i;
-
- memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS);
-
- /* Set up a constant (StrideB == 0) array for each current
- * attribute:
- */
- for (i = 0; i < NR_LEGACY_ATTRIBS; i++) {
- struct gl_client_array *cl = &arrays[i];
-
- /* Size will have to be determined at runtime:
- */
- cl->Size = check_size(ctx->Current.Attrib[i]);
- cl->Stride = 0;
- cl->StrideB = 0;
- cl->Enabled = 1;
- cl->Type = GL_FLOAT;
- cl->Format = GL_RGBA;
- cl->Ptr = (const void *)ctx->Current.Attrib[i];
- cl->_ElementSize = cl->Size * sizeof(GLfloat);
- _mesa_reference_buffer_object(ctx, &cl->BufferObj,
- ctx->Shared->NullBufferObj);
- }
-}
-
-
-static void init_generic_currval(struct gl_context *ctx)
-{
- struct vbo_context *vbo = vbo_context(ctx);
- struct gl_client_array *arrays = vbo->generic_currval;
- GLuint i;
-
- memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
-
- for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
- struct gl_client_array *cl = &arrays[i];
-
- /* This will have to be determined at runtime:
- */
- cl->Size = 1;
- cl->Type = GL_FLOAT;
- cl->Format = GL_RGBA;
- cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i];
- cl->Stride = 0;
- cl->StrideB = 0;
- cl->Enabled = 1;
- cl->_ElementSize = cl->Size * sizeof(GLfloat);
- _mesa_reference_buffer_object(ctx, &cl->BufferObj,
- ctx->Shared->NullBufferObj);
- }
-}
-
-
-static void init_mat_currval(struct gl_context *ctx)
-{
- struct vbo_context *vbo = vbo_context(ctx);
- struct gl_client_array *arrays = vbo->mat_currval;
- GLuint i;
-
- ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX);
-
- memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS);
-
- /* Set up a constant (StrideB == 0) array for each current
- * attribute:
- */
- for (i = 0; i < NR_MAT_ATTRIBS; i++) {
- struct gl_client_array *cl = &arrays[i];
-
- /* Size is fixed for the material attributes, for others will
- * be determined at runtime:
- */
- switch (i - VERT_ATTRIB_GENERIC0) {
- case MAT_ATTRIB_FRONT_SHININESS:
- case MAT_ATTRIB_BACK_SHININESS:
- cl->Size = 1;
- break;
- case MAT_ATTRIB_FRONT_INDEXES:
- case MAT_ATTRIB_BACK_INDEXES:
- cl->Size = 3;
- break;
- default:
- cl->Size = 4;
- break;
- }
-
- cl->Ptr = (const void *)ctx->Light.Material.Attrib[i];
- cl->Type = GL_FLOAT;
- cl->Format = GL_RGBA;
- cl->Stride = 0;
- cl->StrideB = 0;
- cl->Enabled = 1;
- cl->_ElementSize = cl->Size * sizeof(GLfloat);
- _mesa_reference_buffer_object(ctx, &cl->BufferObj,
- ctx->Shared->NullBufferObj);
- }
-}
-
-
-GLboolean _vbo_CreateContext( struct gl_context *ctx )
-{
- struct vbo_context *vbo = CALLOC_STRUCT(vbo_context);
-
- ctx->swtnl_im = (void *)vbo;
-
- /* Initialize the arrayelt helper
- */
- if (!ctx->aelt_context &&
- !_ae_create_context( ctx )) {
- return GL_FALSE;
- }
-
- /* TODO: remove these pointers.
- */
- vbo->legacy_currval = &vbo->currval[VBO_ATTRIB_POS];
- vbo->generic_currval = &vbo->currval[VBO_ATTRIB_GENERIC0];
- vbo->mat_currval = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT];
-
- init_legacy_currval( ctx );
- init_generic_currval( ctx );
- init_mat_currval( ctx );
-
- /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type
- * of vertex program active.
- */
- {
- GLuint i;
-
- /* When no vertex program, pull in the material attributes in
- * the 16..32 generic range.
- */
- for (i = 0; i < 16; i++)
- vbo->map_vp_none[i] = i;
- for (i = 0; i < 12; i++)
- vbo->map_vp_none[16+i] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
- for (i = 0; i < 4; i++)
- vbo->map_vp_none[28+i] = i;
-
- for (i = 0; i < Elements(vbo->map_vp_arb); i++)
- vbo->map_vp_arb[i] = i;
- }
-
-
- /* Hook our functions into exec and compile dispatch tables. These
- * will pretty much be permanently installed, which means that the
- * vtxfmt mechanism can be removed now.
- */
- vbo_exec_init( ctx );
- if (ctx->API == API_OPENGL)
- vbo_save_init( ctx );
-
- _math_init_eval();
-
- return GL_TRUE;
-}
-
-
-void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state )
-{
- vbo_exec_invalidate_state(ctx, new_state);
-}
-
-
-void _vbo_DestroyContext( struct gl_context *ctx )
-{
- struct vbo_context *vbo = vbo_context(ctx);
-
- if (ctx->aelt_context) {
- _ae_destroy_context( ctx );
- ctx->aelt_context = NULL;
- }
-
- if (vbo) {
- GLuint i;
-
- for (i = 0; i < VBO_ATTRIB_MAX; i++) {
- _mesa_reference_buffer_object(ctx, &vbo->currval[i].BufferObj, NULL);
- }
-
- vbo_exec_destroy(ctx);
- if (ctx->API == API_OPENGL)
- vbo_save_destroy(ctx);
- FREE(vbo);
- ctx->swtnl_im = NULL;
- }
-}
-
-
-void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func)
-{
- struct vbo_context *vbo = vbo_context(ctx);
- vbo->draw_prims = func;
-}
-
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "main/api_arrayelt.h"
+#include "main/bufferobj.h"
+#include "math/m_eval.h"
+#include "vbo.h"
+#include "vbo_context.h"
+
+#define NR_MAT_ATTRIBS 12
+
+static GLuint check_size( const GLfloat *attr )
+{
+ if (attr[3] != 1.0) return 4;
+ if (attr[2] != 0.0) return 3;
+ if (attr[1] != 0.0) return 2;
+ return 1;
+}
+
+
+static void init_legacy_currval(struct gl_context *ctx)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct gl_client_array *arrays = vbo->legacy_currval;
+ GLuint i;
+
+ memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_FF_MAX);
+
+ /* Set up a constant (StrideB == 0) array for each current
+ * attribute:
+ */
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
+ struct gl_client_array *cl = &arrays[i];
+
+ /* Size will have to be determined at runtime:
+ */
+ cl->Size = check_size(ctx->Current.Attrib[i]);
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Enabled = 1;
+ cl->Type = GL_FLOAT;
+ cl->Format = GL_RGBA;
+ cl->Ptr = (const void *)ctx->Current.Attrib[i];
+ cl->_ElementSize = cl->Size * sizeof(GLfloat);
+ _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+ ctx->Shared->NullBufferObj);
+ }
+}
+
+
+static void init_generic_currval(struct gl_context *ctx)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct gl_client_array *arrays = vbo->generic_currval;
+ GLuint i;
+
+ memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_GENERIC_MAX);
+
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
+ struct gl_client_array *cl = &arrays[i];
+
+ /* This will have to be determined at runtime:
+ */
+ cl->Size = 1;
+ cl->Type = GL_FLOAT;
+ cl->Format = GL_RGBA;
+ cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i];
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Enabled = 1;
+ cl->_ElementSize = cl->Size * sizeof(GLfloat);
+ _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+ ctx->Shared->NullBufferObj);
+ }
+}
+
+
+static void init_mat_currval(struct gl_context *ctx)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct gl_client_array *arrays = vbo->mat_currval;
+ GLuint i;
+
+ ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX);
+
+ memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS);
+
+ /* Set up a constant (StrideB == 0) array for each current
+ * attribute:
+ */
+ for (i = 0; i < NR_MAT_ATTRIBS; i++) {
+ struct gl_client_array *cl = &arrays[i];
+
+ /* Size is fixed for the material attributes, for others will
+ * be determined at runtime:
+ */
+ switch (i - VERT_ATTRIB_GENERIC0) {
+ case MAT_ATTRIB_FRONT_SHININESS:
+ case MAT_ATTRIB_BACK_SHININESS:
+ cl->Size = 1;
+ break;
+ case MAT_ATTRIB_FRONT_INDEXES:
+ case MAT_ATTRIB_BACK_INDEXES:
+ cl->Size = 3;
+ break;
+ default:
+ cl->Size = 4;
+ break;
+ }
+
+ cl->Ptr = (const void *)ctx->Light.Material.Attrib[i];
+ cl->Type = GL_FLOAT;
+ cl->Format = GL_RGBA;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Enabled = 1;
+ cl->_ElementSize = cl->Size * sizeof(GLfloat);
+ _mesa_reference_buffer_object(ctx, &cl->BufferObj,
+ ctx->Shared->NullBufferObj);
+ }
+}
+
+
+GLboolean _vbo_CreateContext( struct gl_context *ctx )
+{
+ struct vbo_context *vbo = CALLOC_STRUCT(vbo_context);
+
+ ctx->swtnl_im = (void *)vbo;
+
+ /* Initialize the arrayelt helper
+ */
+ if (!ctx->aelt_context &&
+ !_ae_create_context( ctx )) {
+ return GL_FALSE;
+ }
+
+ /* TODO: remove these pointers.
+ */
+ vbo->legacy_currval = &vbo->currval[VBO_ATTRIB_POS];
+ vbo->generic_currval = &vbo->currval[VBO_ATTRIB_GENERIC0];
+ vbo->mat_currval = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT];
+
+ init_legacy_currval( ctx );
+ init_generic_currval( ctx );
+ init_mat_currval( ctx );
+
+ /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type
+ * of vertex program active.
+ */
+ {
+ GLuint i;
+
+ /* When no vertex program, pull in the material attributes in
+ * the generic range.
+ */
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++)
+ vbo->map_vp_none[i] = i;
+ for (i = 0; i < NR_MAT_ATTRIBS; i++)
+ vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)]
+ = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
+ for (i = NR_MAT_ATTRIBS; i < VERT_ATTRIB_GENERIC_MAX; i++)
+ vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] = i;
+
+ for (i = 0; i < Elements(vbo->map_vp_arb); i++)
+ vbo->map_vp_arb[i] = i;
+ }
+
+
+ /* Hook our functions into exec and compile dispatch tables. These
+ * will pretty much be permanently installed, which means that the
+ * vtxfmt mechanism can be removed now.
+ */
+ vbo_exec_init( ctx );
+ if (ctx->API == API_OPENGL)
+ vbo_save_init( ctx );
+
+ _math_init_eval();
+
+ return GL_TRUE;
+}
+
+
+void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state )
+{
+ vbo_exec_invalidate_state(ctx, new_state);
+}
+
+
+void _vbo_DestroyContext( struct gl_context *ctx )
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+
+ if (ctx->aelt_context) {
+ _ae_destroy_context( ctx );
+ ctx->aelt_context = NULL;
+ }
+
+ if (vbo) {
+ GLuint i;
+
+ for (i = 0; i < VBO_ATTRIB_MAX; i++) {
+ _mesa_reference_buffer_object(ctx, &vbo->currval[i].BufferObj, NULL);
+ }
+
+ vbo_exec_destroy(ctx);
+ if (ctx->API == API_OPENGL)
+ vbo_save_destroy(ctx);
+ FREE(vbo);
+ ctx->swtnl_im = NULL;
+ }
+}
+
+
+void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ vbo->draw_prims = func;
+}
+
diff --git a/mesalib/src/mesa/vbo/vbo_exec.h b/mesalib/src/mesa/vbo/vbo_exec.h
index 8d6b8f95a..cfed8e86d 100644
--- a/mesalib/src/mesa/vbo/vbo_exec.h
+++ b/mesalib/src/mesa/vbo/vbo_exec.h
@@ -125,8 +125,8 @@ struct vbo_exec_context
/* These just mirror the current arrayobj (todo: make arrayobj
* look like this and remove the mirror):
*/
- const struct gl_client_array *legacy_array[16];
- const struct gl_client_array *generic_array[16];
+ const struct gl_client_array *legacy_array[VERT_ATTRIB_FF_MAX];
+ const struct gl_client_array *generic_array[VERT_ATTRIB_GENERIC_MAX];
/* Arrays and current values manipulated according to program
* mode, etc. These are the attributes as seen by vertex
diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c
index 62e7d03f3..70551e0e1 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_api.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_api.c
@@ -1091,15 +1091,23 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
struct gl_client_array *arrays = exec->vtx.arrays;
unsigned i;
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
-
- for (i = 0; i < 16; ++i) {
- arrays[i ].BufferObj = NULL;
- arrays[i + 16].BufferObj = NULL;
- _mesa_reference_buffer_object(ctx, &arrays[i ].BufferObj,
+ memcpy(arrays, vbo->legacy_currval,
+ VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
+ struct gl_client_array *array;
+ array = &arrays[VERT_ATTRIB_FF(i)];
+ array->BufferObj = NULL;
+ _mesa_reference_buffer_object(ctx, &arrays->BufferObj,
vbo->legacy_currval[i].BufferObj);
- _mesa_reference_buffer_object(ctx, &arrays[i + 16].BufferObj,
+ }
+
+ memcpy(arrays + VERT_ATTRIB_GENERIC(0), vbo->generic_currval,
+ VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0]));
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) {
+ struct gl_client_array *array;
+ array = &arrays[VERT_ATTRIB_GENERIC(i)];
+ array->BufferObj = NULL;
+ _mesa_reference_buffer_object(ctx, &array->BufferObj,
vbo->generic_currval[i].BufferObj);
}
}
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index 7023380a1..97221a54d 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -270,11 +270,11 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType,
const void *elemMap;
GLint i, k;
- if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
+ if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj)) {
elemMap = ctx->Driver.MapBufferRange(ctx, 0,
- ctx->Array.ElementArrayBufferObj->Size,
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Size,
GL_MAP_READ_BIT,
- ctx->Array.ElementArrayBufferObj);
+ ctx->Array.ArrayObj->ElementArrayBufferObj);
elements = ADD_POINTERS(elements, elemMap);
}
@@ -297,29 +297,15 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType,
}
/* check element j of each enabled array */
- check_array_data(ctx, &arrayObj->Vertex, VERT_ATTRIB_POS, j);
- check_array_data(ctx, &arrayObj->Normal, VERT_ATTRIB_NORMAL, j);
- check_array_data(ctx, &arrayObj->Color, VERT_ATTRIB_COLOR0, j);
- check_array_data(ctx, &arrayObj->SecondaryColor, VERT_ATTRIB_COLOR1, j);
- for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
- check_array_data(ctx, &arrayObj->TexCoord[k], VERT_ATTRIB_TEX0 + k, j);
- }
for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
- check_array_data(ctx, &arrayObj->VertexAttrib[k],
- VERT_ATTRIB_GENERIC0 + k, j);
+ check_array_data(ctx, &arrayObj->VertexAttrib[k], k, j);
}
}
- if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
- ctx->Driver.UnmapBuffer(ctx, ctx->Array.ElementArrayBufferObj);
+ if (_mesa_is_bufferobj(arrayObj->ElementArrayBufferObj)) {
+ ctx->Driver.UnmapBuffer(ctx, ctx->Array.ArrayObj->ElementArrayBufferObj);
}
- unmap_array_buffer(ctx, &arrayObj->Vertex);
- unmap_array_buffer(ctx, &arrayObj->Normal);
- unmap_array_buffer(ctx, &arrayObj->Color);
- for (k = 0; k < Elements(arrayObj->TexCoord); k++) {
- unmap_array_buffer(ctx, &arrayObj->TexCoord[k]);
- }
for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) {
unmap_array_buffer(ctx, &arrayObj->VertexAttrib[k]);
}
@@ -398,29 +384,12 @@ bind_array_obj(struct gl_context *ctx)
struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
GLuint i;
- /* TODO: Fix the ArrayObj struct to keep legacy arrays in an array
- * rather than as individual named arrays. Then this function can
- * go away.
- */
- exec->array.legacy_array[VERT_ATTRIB_POS] = &arrayObj->Vertex;
- exec->array.legacy_array[VERT_ATTRIB_WEIGHT] = &arrayObj->Weight;
- exec->array.legacy_array[VERT_ATTRIB_NORMAL] = &arrayObj->Normal;
- exec->array.legacy_array[VERT_ATTRIB_COLOR0] = &arrayObj->Color;
- exec->array.legacy_array[VERT_ATTRIB_COLOR1] = &arrayObj->SecondaryColor;
- exec->array.legacy_array[VERT_ATTRIB_FOG] = &arrayObj->FogCoord;
- exec->array.legacy_array[VERT_ATTRIB_COLOR_INDEX] = &arrayObj->Index;
- if (arrayObj->PointSize.Enabled) {
- /* this aliases COLOR_INDEX */
- exec->array.legacy_array[VERT_ATTRIB_POINT_SIZE] = &arrayObj->PointSize;
- }
- exec->array.legacy_array[VERT_ATTRIB_EDGEFLAG] = &arrayObj->EdgeFlag;
-
- for (i = 0; i < Elements(arrayObj->TexCoord); i++)
- exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i];
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++)
+ exec->array.legacy_array[i] = &arrayObj->VertexAttrib[VERT_ATTRIB_FF(i)];
- for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) {
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
assert(i < Elements(exec->array.generic_array));
- exec->array.generic_array[i] = &arrayObj->VertexAttrib[i];
+ exec->array.generic_array[i] = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
}
}
@@ -439,7 +408,7 @@ recalculate_input_bindings(struct gl_context *ctx)
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
const struct gl_client_array **inputs = &exec->array.inputs[0];
- GLbitfield const_inputs = 0x0;
+ GLbitfield64 const_inputs = 0x0;
GLuint i;
switch (get_program_mode(ctx)) {
@@ -449,26 +418,26 @@ recalculate_input_bindings(struct gl_context *ctx)
* generic slots. This is the only situation where material values
* are available as per-vertex attributes.
*/
- for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else {
inputs[i] = &vbo->legacy_currval[i];
- const_inputs |= 1 << i;
+ const_inputs |= VERT_BIT(i);
}
}
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
- inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i];
- const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
+ inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->mat_currval[i];
+ const_inputs |= VERT_BIT_GENERIC(i);
}
/* Could use just about anything, just to fill in the empty
* slots:
*/
- for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_MAX - VERT_ATTRIB_GENERIC0; i++) {
- inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
- const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
+ for (i = MAT_ATTRIB_MAX; i < VERT_ATTRIB_GENERIC_MAX; i++) {
+ inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i];
+ const_inputs |= VERT_BIT_GENERIC(i);
}
/* There is no need to make _NEW_ARRAY dirty here for the TnL program,
@@ -485,23 +454,24 @@ recalculate_input_bindings(struct gl_context *ctx)
* conventional, legacy arrays. No materials, and the generic
* slots are vacant.
*/
- for (i = 0; i <= VERT_ATTRIB_TEX7; i++) {
- if (exec->array.generic_array[i]->Enabled)
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
+ if (i < VERT_ATTRIB_GENERIC_MAX
+ && exec->array.generic_array[i]->Enabled)
inputs[i] = exec->array.generic_array[i];
else if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else {
inputs[i] = &vbo->legacy_currval[i];
- const_inputs |= 1 << i;
+ const_inputs |= VERT_BIT_FF(i);
}
}
/* Could use just about anything, just to fill in the empty
* slots:
*/
- for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) {
- inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0];
- const_inputs |= 1 << i;
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
+ inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i];
+ const_inputs |= VERT_BIT_GENERIC(i);
}
ctx->NewState |= _NEW_ARRAY;
@@ -521,24 +491,24 @@ recalculate_input_bindings(struct gl_context *ctx)
inputs[0] = exec->array.legacy_array[0];
else {
inputs[0] = &vbo->legacy_currval[0];
- const_inputs |= 1 << 0;
+ const_inputs |= VERT_BIT_POS;
}
- for (i = 1; i <= VERT_ATTRIB_TEX7; i++) {
+ for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) {
if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else {
inputs[i] = &vbo->legacy_currval[i];
- const_inputs |= 1 << i;
+ const_inputs |= VERT_BIT_FF(i);
}
}
- for (i = 1; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
+ for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {
if (exec->array.generic_array[i]->Enabled)
- inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i];
+ inputs[VERT_ATTRIB_GENERIC(i)] = exec->array.generic_array[i];
else {
- inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
- const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
+ inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i];
+ const_inputs |= VERT_BIT_GENERIC(i);
}
}
@@ -547,7 +517,7 @@ recalculate_input_bindings(struct gl_context *ctx)
break;
}
- _mesa_set_varying_vp_inputs( ctx, ~const_inputs );
+ _mesa_set_varying_vp_inputs( ctx, VERT_BIT_ALL & (~const_inputs) );
}
@@ -727,15 +697,15 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
{
const GLvoid *map =
ctx->Driver.MapBufferRange(ctx, 0,
- ctx->Array.ElementArrayBufferObj->Size,
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Size,
GL_MAP_READ_BIT,
- ctx->Array.ElementArrayBufferObj);
+ ctx->Array.ArrayObj->ElementArrayBufferObj);
switch (type) {
case GL_UNSIGNED_BYTE:
{
const GLubyte *us = (const GLubyte *) map;
GLint i;
- for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) {
+ for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size; i++) {
printf("%02x ", us[i]);
if (i % 32 == 31)
printf("\n");
@@ -747,7 +717,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
{
const GLushort *us = (const GLushort *) map;
GLint i;
- for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) {
+ for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size / 2; i++) {
printf("%04x ", us[i]);
if (i % 16 == 15)
printf("\n");
@@ -759,7 +729,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
{
const GLuint *us = (const GLuint *) map;
GLint i;
- for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) {
+ for (i = 0; i < ctx->Array.ArrayObj->ElementArrayBufferObj->Size / 4; i++) {
printf("%08x ", us[i]);
if (i % 8 == 7)
printf("\n");
@@ -771,7 +741,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
;
}
- ctx->Driver.UnmapBuffer(ctx, ctx->Array.ElementArrayBufferObj);
+ ctx->Driver.UnmapBuffer(ctx, ctx->Array.ArrayObj->ElementArrayBufferObj);
}
@@ -807,7 +777,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
ib.count = count;
ib.type = type;
- ib.obj = ctx->Array.ElementArrayBufferObj;
+ ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
ib.ptr = indices;
prim[0].begin = 1;
@@ -909,8 +879,8 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
"\tThis should probably be fixed in the application.",
start, end, count, type, indices,
ctx->Array.ArrayObj->_MaxElement - 1,
- ctx->Array.ElementArrayBufferObj->Name,
- (int) ctx->Array.ElementArrayBufferObj->Size);
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
+ (int) ctx->Array.ArrayObj->ElementArrayBufferObj->Size);
}
if (0)
@@ -924,7 +894,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
*/
if (0) {
GLuint max = _mesa_max_buffer_index(ctx, count, type, indices,
- ctx->Array.ElementArrayBufferObj);
+ ctx->Array.ArrayObj->ElementArrayBufferObj);
if (max >= ctx->Array.ArrayObj->_MaxElement) {
if (warnCount < 10) {
_mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, "
@@ -934,8 +904,8 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
"\tSkipping the glDrawRangeElements() call",
start, end, count, type, indices, max,
ctx->Array.ArrayObj->_MaxElement - 1,
- ctx->Array.ElementArrayBufferObj->Name,
- (int) ctx->Array.ElementArrayBufferObj->Size);
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
+ (int) ctx->Array.ArrayObj->ElementArrayBufferObj->Size);
}
}
/* XXX we could also find the min index and compare to 'start'
@@ -958,7 +928,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
"(start %u, end %u, type 0x%x, count %d) ElemBuf %u, "
"base %d\n",
start, end, type, count,
- ctx->Array.ElementArrayBufferObj->Name,
+ ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
basevertex);
}
@@ -1171,13 +1141,13 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
* subranges of the index buffer as one large index buffer may lead to
* us reading unmapped memory.
*/
- if (!_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj))
+ if (!_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj))
fallback = GL_TRUE;
if (!fallback) {
ib.count = (max_index_ptr - min_index_ptr) / index_type_size;
ib.type = type;
- ib.obj = ctx->Array.ElementArrayBufferObj;
+ ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
ib.ptr = (void *)min_index_ptr;
for (i = 0; i < primcount; i++) {
@@ -1204,7 +1174,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
for (i = 0; i < primcount; i++) {
ib.count = count[i];
ib.type = type;
- ib.obj = ctx->Array.ElementArrayBufferObj;
+ ib.obj = ctx->Array.ArrayObj->ElementArrayBufferObj;
ib.ptr = indices[i];
prim[0].begin = 1;
diff --git a/mesalib/src/mesa/vbo/vbo_exec_draw.c b/mesalib/src/mesa/vbo/vbo_exec_draw.c
index efb6dd10a..4962b54e1 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_draw.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_draw.c
@@ -166,19 +166,19 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
const GLuint count = exec->vtx.vert_count;
const GLuint *map;
GLuint attr;
- GLbitfield varying_inputs = 0x0;
+ GLbitfield64 varying_inputs = 0x0;
/* Install the default (ie Current) attributes first, then overlay
* all active ones.
*/
switch (get_program_mode(exec->ctx)) {
case VP_NONE:
- for (attr = 0; attr < 16; attr++) {
+ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
}
for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
- ASSERT(attr + 16 < Elements(exec->vtx.inputs));
- exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr];
+ ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs));
+ exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->mat_currval[attr];
}
map = vbo->map_vp_none;
break;
@@ -188,10 +188,12 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
* occurred. NV vertex programs cannot access material values,
* nor attributes greater than VERT_ATTRIB_TEX7.
*/
- for (attr = 0; attr < 16; attr++) {
+ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
- ASSERT(attr + 16 < Elements(exec->vtx.inputs));
- exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr];
+ }
+ for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
+ ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs));
+ exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->generic_currval[attr];
}
map = vbo->map_vp_arb;
@@ -201,9 +203,9 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
*/
if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 &&
(ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) {
- exec->vtx.inputs[16] = exec->vtx.inputs[0];
- exec->vtx.attrsz[16] = exec->vtx.attrsz[0];
- exec->vtx.attrptr[16] = exec->vtx.attrptr[0];
+ exec->vtx.inputs[VERT_ATTRIB_GENERIC0] = exec->vtx.inputs[0];
+ exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0];
+ exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0];
exec->vtx.attrsz[0] = 0;
}
break;
@@ -248,7 +250,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
exec->vtx.bufferobj);
arrays[attr]._MaxElement = count; /* ??? */
- varying_inputs |= 1 << attr;
+ varying_inputs |= VERT_BIT(attr);
ctx->NewState |= _NEW_ARRAY;
}
}
diff --git a/mesalib/src/mesa/vbo/vbo_save.c b/mesalib/src/mesa/vbo/vbo_save.c
index 4efc6e9d2..e02706191 100644
--- a/mesalib/src/mesa/vbo/vbo_save.c
+++ b/mesalib/src/mesa/vbo/vbo_save.c
@@ -1,123 +1,131 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.2
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "main/mtypes.h"
-#include "main/bufferobj.h"
-#include "main/imports.h"
-#include "main/mfeatures.h"
-
-#include "vbo_context.h"
-
-
-#if FEATURE_dlist
-
-
-static void vbo_save_callback_init( struct gl_context *ctx )
-{
- ctx->Driver.NewList = vbo_save_NewList;
- ctx->Driver.EndList = vbo_save_EndList;
- ctx->Driver.SaveFlushVertices = vbo_save_SaveFlushVertices;
- ctx->Driver.BeginCallList = vbo_save_BeginCallList;
- ctx->Driver.EndCallList = vbo_save_EndCallList;
- ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin;
-}
-
-
-
-void vbo_save_init( struct gl_context *ctx )
-{
- struct vbo_context *vbo = vbo_context(ctx);
- struct vbo_save_context *save = &vbo->save;
-
- save->ctx = ctx;
-
- vbo_save_api_init( save );
- vbo_save_callback_init(ctx);
-
- {
- struct gl_client_array *arrays = save->arrays;
- unsigned i;
-
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
-
- for (i = 0; i < 16; ++i) {
- arrays[i ].BufferObj = NULL;
- arrays[i + 16].BufferObj = NULL;
- _mesa_reference_buffer_object(ctx, &arrays[i ].BufferObj,
- vbo->legacy_currval[i].BufferObj);
- _mesa_reference_buffer_object(ctx, &arrays[i + 16].BufferObj,
- vbo->generic_currval[i].BufferObj);
- }
- }
-
- ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
-}
-
-
-void vbo_save_destroy( struct gl_context *ctx )
-{
- struct vbo_context *vbo = vbo_context(ctx);
- struct vbo_save_context *save = &vbo->save;
- GLuint i;
-
- if (save->prim_store) {
- if ( --save->prim_store->refcount == 0 ) {
- FREE( save->prim_store );
- save->prim_store = NULL;
- }
- if ( --save->vertex_store->refcount == 0 ) {
- _mesa_reference_buffer_object(ctx,
- &save->vertex_store->bufferobj, NULL);
- FREE( save->vertex_store );
- save->vertex_store = NULL;
- }
- }
-
- for (i = 0; i < VBO_ATTRIB_MAX; i++) {
- _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL);
- }
-}
-
-
-
-
-/* Note that this can occur during the playback of a display list:
- */
-void vbo_save_fallback( struct gl_context *ctx, GLboolean fallback )
-{
- struct vbo_save_context *save = &vbo_context(ctx)->save;
-
- if (fallback)
- save->replay_flags |= VBO_SAVE_FALLBACK;
- else
- save->replay_flags &= ~VBO_SAVE_FALLBACK;
-}
-
-
-#endif /* FEATURE_dlist */
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.2
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#include "main/mtypes.h"
+#include "main/bufferobj.h"
+#include "main/imports.h"
+#include "main/mfeatures.h"
+
+#include "vbo_context.h"
+
+
+#if FEATURE_dlist
+
+
+static void vbo_save_callback_init( struct gl_context *ctx )
+{
+ ctx->Driver.NewList = vbo_save_NewList;
+ ctx->Driver.EndList = vbo_save_EndList;
+ ctx->Driver.SaveFlushVertices = vbo_save_SaveFlushVertices;
+ ctx->Driver.BeginCallList = vbo_save_BeginCallList;
+ ctx->Driver.EndCallList = vbo_save_EndCallList;
+ ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin;
+}
+
+
+
+void vbo_save_init( struct gl_context *ctx )
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct vbo_save_context *save = &vbo->save;
+
+ save->ctx = ctx;
+
+ vbo_save_api_init( save );
+ vbo_save_callback_init(ctx);
+
+ {
+ struct gl_client_array *arrays = save->arrays;
+ unsigned i;
+
+ memcpy(arrays, vbo->legacy_currval,
+ VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
+ for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
+ struct gl_client_array *array;
+ array = &arrays[VERT_ATTRIB_FF(i)];
+ array->BufferObj = NULL;
+ _mesa_reference_buffer_object(ctx, &arrays->BufferObj,
+ vbo->legacy_currval[i].BufferObj);
+ }
+
+ memcpy(arrays + VERT_ATTRIB_GENERIC(0), vbo->generic_currval,
+ VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0]));
+ for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) {
+ struct gl_client_array *array;
+ array = &arrays[VERT_ATTRIB_GENERIC(i)];
+ array->BufferObj = NULL;
+ _mesa_reference_buffer_object(ctx, &array->BufferObj,
+ vbo->generic_currval[i].BufferObj);
+ }
+ }
+
+ ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+}
+
+
+void vbo_save_destroy( struct gl_context *ctx )
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct vbo_save_context *save = &vbo->save;
+ GLuint i;
+
+ if (save->prim_store) {
+ if ( --save->prim_store->refcount == 0 ) {
+ FREE( save->prim_store );
+ save->prim_store = NULL;
+ }
+ if ( --save->vertex_store->refcount == 0 ) {
+ _mesa_reference_buffer_object(ctx,
+ &save->vertex_store->bufferobj, NULL);
+ FREE( save->vertex_store );
+ save->vertex_store = NULL;
+ }
+ }
+
+ for (i = 0; i < VBO_ATTRIB_MAX; i++) {
+ _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL);
+ }
+}
+
+
+
+
+/* Note that this can occur during the playback of a display list:
+ */
+void vbo_save_fallback( struct gl_context *ctx, GLboolean fallback )
+{
+ struct vbo_save_context *save = &vbo_context(ctx)->save;
+
+ if (fallback)
+ save->replay_flags |= VBO_SAVE_FALLBACK;
+ else
+ save->replay_flags &= ~VBO_SAVE_FALLBACK;
+}
+
+
+#endif /* FEATURE_dlist */
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index 64da7ac49..9d8bada04 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -1119,9 +1119,9 @@ _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type,
_ae_map_vbos(ctx);
- if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj))
+ if (_mesa_is_bufferobj(ctx->Array.ArrayObj->ElementArrayBufferObj))
indices =
- ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Pointer, indices);
+ ADD_POINTERS(ctx->Array.ArrayObj->ElementArrayBufferObj->Pointer, indices);
vbo_save_NotifyBegin(ctx, (mode | VBO_SAVE_PRIM_WEAK |
VBO_SAVE_PRIM_NO_CURRENT_UPDATE));
diff --git a/mesalib/src/mesa/vbo/vbo_save_draw.c b/mesalib/src/mesa/vbo/vbo_save_draw.c
index 6cda831aa..0773786b3 100644
--- a/mesalib/src/mesa/vbo/vbo_save_draw.c
+++ b/mesalib/src/mesa/vbo/vbo_save_draw.c
@@ -137,7 +137,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
const GLuint *map;
GLuint attr;
GLubyte node_attrsz[VBO_ATTRIB_MAX]; /* copy of node->attrsz[] */
- GLbitfield varying_inputs = 0x0;
+ GLbitfield64 varying_inputs = 0x0;
memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz));
@@ -146,11 +146,11 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
*/
switch (get_program_mode(ctx)) {
case VP_NONE:
- for (attr = 0; attr < 16; attr++) {
+ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
save->inputs[attr] = &vbo->legacy_currval[attr];
}
for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
- save->inputs[attr + 16] = &vbo->mat_currval[attr];
+ save->inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->mat_currval[attr];
}
map = vbo->map_vp_none;
break;
@@ -160,9 +160,11 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
* occurred. NV vertex programs cannot access material values,
* nor attributes greater than VERT_ATTRIB_TEX7.
*/
- for (attr = 0; attr < 16; attr++) {
+ for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
save->inputs[attr] = &vbo->legacy_currval[attr];
- save->inputs[attr + 16] = &vbo->generic_currval[attr];
+ }
+ for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
+ save->inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->generic_currval[attr];
}
map = vbo->map_vp_arb;
@@ -172,8 +174,8 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
*/
if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 &&
(ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) {
- save->inputs[16] = save->inputs[0];
- node_attrsz[16] = node_attrsz[0];
+ save->inputs[VERT_ATTRIB_GENERIC0] = save->inputs[0];
+ node_attrsz[VERT_ATTRIB_GENERIC0] = node_attrsz[0];
node_attrsz[0] = 0;
}
break;
@@ -204,7 +206,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
assert(arrays[attr].BufferObj->Name);
buffer_offset += node->attrsz[src] * sizeof(GLfloat);
- varying_inputs |= 1<<attr;
+ varying_inputs |= VERT_BIT(attr);
ctx->NewState |= _NEW_ARRAY;
}
}