diff options
Diffstat (limited to 'src/mesa/tnl/t_array_import.c')
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 325 |
1 files changed, 104 insertions, 221 deletions
diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index a888894..16874df 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -37,7 +37,6 @@ #include "t_array_import.h" #include "t_context.h" -#include "t_imm_debug.h" static void _tnl_import_vertex( GLcontext *ctx, @@ -46,7 +45,7 @@ static void _tnl_import_vertex( GLcontext *ctx, { struct gl_client_array *tmp; GLboolean is_writeable = 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; const GLubyte *data; tmp = _ac_import_vertex(ctx, @@ -56,21 +55,11 @@ static void _tnl_import_vertex( GLcontext *ctx, writeable, &is_writeable); -#if 0 - /* guess we really don't need to add pointers here - BP */ - data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); -#else data = tmp->Ptr; -#endif inputs->Obj.data = (GLfloat (*)[4]) data; inputs->Obj.start = (GLfloat *) data; inputs->Obj.stride = tmp->StrideB; inputs->Obj.size = tmp->Size; - inputs->Obj.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Obj.stride != 4*sizeof(GLfloat)) - inputs->Obj.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Obj.flags |= VEC_NOT_WRITEABLE; } static void _tnl_import_normal( GLcontext *ctx, @@ -79,73 +68,72 @@ static void _tnl_import_normal( GLcontext *ctx, { struct gl_client_array *tmp; GLboolean is_writeable = 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; const GLubyte *data; tmp = _ac_import_normal(ctx, GL_FLOAT, stride ? 3*sizeof(GLfloat) : 0, writeable, &is_writeable); -#if 0 - data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); -#else data = tmp->Ptr; -#endif inputs->Normal.data = (GLfloat (*)[4]) data; inputs->Normal.start = (GLfloat *) data; inputs->Normal.stride = tmp->StrideB; - inputs->Normal.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Normal.stride != 3*sizeof(GLfloat)) - inputs->Normal.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Normal.flags |= VEC_NOT_WRITEABLE; } static void _tnl_import_color( GLcontext *ctx, - GLenum type, GLboolean writeable, GLboolean stride ) { struct gl_client_array *tmp; GLboolean is_writeable = 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + GLubyte *data; tmp = _ac_import_color(ctx, - type, + GL_FLOAT, stride ? 4*sizeof(GLfloat) : 0, 4, writeable, &is_writeable); - inputs->Color = *tmp; + data = tmp->Ptr; + inputs->Color.data = (GLfloat (*)[4]) data; + inputs->Color.start = (GLfloat *) data; + inputs->Color.stride = tmp->StrideB; + inputs->Color.size = tmp->Size; } static void _tnl_import_secondarycolor( GLcontext *ctx, - GLenum type, GLboolean writeable, GLboolean stride ) { struct gl_client_array *tmp; GLboolean is_writeable = 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + GLubyte *data; tmp = _ac_import_secondarycolor(ctx, - type, + GL_FLOAT, stride ? 4*sizeof(GLfloat) : 0, 4, writeable, &is_writeable); - inputs->SecondaryColor = *tmp; + data = tmp->Ptr; + inputs->SecondaryColor.data = (GLfloat (*)[4]) data; + inputs->SecondaryColor.start = (GLfloat *) data; + inputs->SecondaryColor.stride = tmp->StrideB; + inputs->SecondaryColor.size = tmp->Size; } static void _tnl_import_fogcoord( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; const GLubyte *data; @@ -154,47 +142,29 @@ static void _tnl_import_fogcoord( GLcontext *ctx, stride ? sizeof(GLfloat) : 0, writeable, &is_writeable); -#if 0 - data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); -#else data = tmp->Ptr; -#endif inputs->FogCoord.data = (GLfloat (*)[4]) data; inputs->FogCoord.start = (GLfloat *) data; inputs->FogCoord.stride = tmp->StrideB; - inputs->FogCoord.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->FogCoord.stride != sizeof(GLfloat)) - inputs->FogCoord.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->FogCoord.flags |= VEC_NOT_WRITEABLE; } static void _tnl_import_index( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; const GLubyte *data; - tmp = _ac_import_index(ctx, GL_UNSIGNED_INT, - stride ? sizeof(GLuint) : 0, writeable, + tmp = _ac_import_index(ctx, GL_FLOAT, + stride ? sizeof(GLfloat) : 0, writeable, &is_writeable); -#if 0 - data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); -#else data = tmp->Ptr; -#endif - inputs->Index.data = (GLuint *) data; - inputs->Index.start = (GLuint *) data; + inputs->Index.data = (GLfloat (*)[4]) data; + inputs->Index.start = (GLfloat *) data; inputs->Index.stride = tmp->StrideB; - inputs->Index.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Index.stride != sizeof(GLuint)) - inputs->Index.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Index.flags |= VEC_NOT_WRITEABLE; } @@ -203,7 +173,7 @@ static void _tnl_import_texcoord( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; const GLubyte *data; @@ -214,20 +184,11 @@ static void _tnl_import_texcoord( GLcontext *ctx, writeable, &is_writeable); -#if 0 - data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); -#else data = tmp->Ptr; -#endif inputs->TexCoord[unit].data = (GLfloat (*)[4]) data; inputs->TexCoord[unit].start = (GLfloat *) data; inputs->TexCoord[unit].stride = tmp->StrideB; inputs->TexCoord[unit].size = tmp->Size; - inputs->TexCoord[unit].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->TexCoord[unit].stride != 4*sizeof(GLfloat)) - inputs->TexCoord[unit].flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->TexCoord[unit].flags |= VEC_NOT_WRITEABLE; } @@ -235,29 +196,18 @@ static void _tnl_import_edgeflag( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; const GLubyte *data; tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE, - stride ? sizeof(GLubyte) : 0, + sizeof(GLubyte), 0, &is_writeable); -#if 0 - data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); -#else data = tmp->Ptr; -#endif - inputs->EdgeFlag.data = (GLubyte *) data; - inputs->EdgeFlag.start = (GLubyte *) data; - inputs->EdgeFlag.stride = tmp->StrideB; - inputs->EdgeFlag.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->EdgeFlag.stride != sizeof(GLubyte)) - inputs->EdgeFlag.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->EdgeFlag.flags |= VEC_NOT_WRITEABLE; + inputs->EdgeFlag = (GLubyte *) data; } @@ -267,7 +217,7 @@ static void _tnl_import_attrib( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; + struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; const GLubyte *data; @@ -278,98 +228,15 @@ static void _tnl_import_attrib( GLcontext *ctx, writeable, &is_writeable); -#if 0 - data = ADD_POINTERS(tmp->Ptr, tmp->BufferObj->Data); -#else data = tmp->Ptr; -#endif inputs->Attribs[index].data = (GLfloat (*)[4]) data; inputs->Attribs[index].start = (GLfloat *) data; inputs->Attribs[index].stride = tmp->StrideB; inputs->Attribs[index].size = tmp->Size; - inputs->Attribs[index].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Attribs[index].stride != 4 * sizeof(GLfloat)) - inputs->Attribs[index].flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Attribs[index].flags |= VEC_NOT_WRITEABLE; } -/** - * Callback for VB stages that need to improve the quality of arrays - * bound to the VB. This is only necessary for client arrays which - * have not been transformed at any point in the pipeline. - * \param required - bitmask of VERT_*_BIT flags - * \param flags - bitmask of VEC_* flags (ex: VEC_NOT_WRITABLE) - */ -static void _tnl_upgrade_client_data( GLcontext *ctx, - GLuint required, - GLuint flags ) -{ - GLuint i; - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLboolean writeable = (flags & VEC_NOT_WRITEABLE) != 0; - GLboolean stride = (flags & VEC_BAD_STRIDE) != 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - GLuint ca_flags = 0; - (void) inputs; - - if (writeable || stride) ca_flags |= CA_CLIENT_DATA; - - if ((required & VERT_BIT_CLIP) && VB->ClipPtr == VB->ObjPtr) - required |= VERT_BIT_POS; - -/* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */ - - if ((required & VERT_BIT_POS) && (VB->ObjPtr->flags & flags)) { - ASSERT(VB->ObjPtr == &inputs->Obj); - _tnl_import_vertex( ctx, writeable, stride ); - VB->importable_data &= ~(VERT_BIT_POS|VERT_BIT_CLIP); - } - - if ((required & VERT_BIT_NORMAL) && (VB->NormalPtr->flags & flags)) { - ASSERT(VB->NormalPtr == &inputs->Normal); - _tnl_import_normal( ctx, writeable, stride ); - VB->importable_data &= ~VERT_BIT_NORMAL; - } - - if ((required & VERT_BIT_COLOR0) && (VB->ColorPtr[0]->Flags & ca_flags)) { - ASSERT(VB->ColorPtr[0] == &inputs->Color); - _tnl_import_color( ctx, GL_FLOAT, writeable, stride ); - VB->importable_data &= ~VERT_BIT_COLOR0; - } - - if ((required & VERT_BIT_COLOR1) && - (VB->SecondaryColorPtr[0]->Flags & ca_flags)) { - ASSERT(VB->SecondaryColorPtr[0] == &inputs->SecondaryColor); - _tnl_import_secondarycolor( ctx, GL_FLOAT, writeable, stride ); - VB->importable_data &= ~VERT_BIT_COLOR1; - } - - if ((required & VERT_BIT_FOG) - && (VB->FogCoordPtr->flags & flags)) { - ASSERT(VB->FogCoordPtr == &inputs->FogCoord); - _tnl_import_fogcoord( ctx, writeable, stride ); - VB->importable_data &= ~VERT_BIT_FOG; - } - - if ((required & VERT_BIT_INDEX) && (VB->IndexPtr[0]->flags & flags)) { - ASSERT(VB->IndexPtr[0] == &inputs->Index); - _tnl_import_index( ctx, writeable, stride ); - VB->importable_data &= ~VERT_BIT_INDEX; - } - - if (required & VERT_BITS_TEX_ANY) - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) - if ((required & VERT_BIT_TEX(i)) && (VB->TexCoordPtr[i]->flags & flags)) { - ASSERT(VB->TexCoordPtr[i] == &inputs->TexCoord[i]); - _tnl_import_texcoord( ctx, i, writeable, stride ); - VB->importable_data &= ~VERT_BIT_TEX(i); - } - - /* XXX not sure what to do here for vertex program arrays */ -} @@ -378,28 +245,15 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; GLuint inputs = tnl->pipeline.inputs; - struct vertex_arrays *tmp = &tnl->array_inputs; - -/* _mesa_debug(ctx, "%s %d..%d // %d..%d\n", __FUNCTION__, */ -/* start, count, ctx->Array.LockFirst, ctx->Array.LockCount); */ -/* _tnl_print_vert_flags(" inputs", inputs); */ -/* _tnl_print_vert_flags(" _Enabled", ctx->Array._Enabled); */ -/* _tnl_print_vert_flags(" importable", inputs & VERT_BITS_FIXUP); */ + struct tnl_vertex_arrays *tmp = &tnl->array_inputs; + GLuint i; VB->Count = count - start; - VB->FirstClipped = VB->Count; VB->Elts = NULL; - VB->MaterialMask = NULL; - VB->Material = NULL; - VB->Flag = NULL; - VB->Primitive = tnl->tmp_primitive; - VB->PrimitiveLength = tnl->tmp_primitive_length; - VB->import_data = _tnl_upgrade_client_data; - VB->importable_data = inputs & VERT_BITS_FIXUP; if (ctx->Array.LockCount) { - ASSERT(start == (GLint) ctx->Array.LockFirst); - ASSERT(count == (GLint) ctx->Array.LockCount); + assert(start == (GLint) ctx->Array.LockFirst); + assert(count == (GLint) ctx->Array.LockCount); } _ac_import_range( ctx, start, count ); @@ -416,63 +270,92 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) VB->AttribPtr[index] = &tmp->Attribs[index]; } } + else { + + /* + * Conventional attributes + */ + if (inputs & _TNL_BIT_POS) { + _tnl_import_vertex( ctx, 0, 0 ); + tmp->Obj.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_POS] = &tmp->Obj; + } - /* - * Conventional attributes - */ - if (inputs & VERT_BIT_POS) { - _tnl_import_vertex( ctx, 0, 0 ); - tmp->Obj.count = VB->Count; - VB->ObjPtr = &tmp->Obj; - } - - if (inputs & VERT_BIT_NORMAL) { - _tnl_import_normal( ctx, 0, 0 ); - tmp->Normal.count = VB->Count; - VB->NormalPtr = &tmp->Normal; - } - - if (inputs & VERT_BIT_COLOR0) { - _tnl_import_color( ctx, 0, 0, 0 ); - VB->ColorPtr[0] = &tmp->Color; - VB->ColorPtr[1] = 0; - } + if (inputs & _TNL_BIT_NORMAL) { + _tnl_import_normal( ctx, 0, 0 ); + tmp->Normal.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_NORMAL] = &tmp->Normal; + } - if (inputs & VERT_BITS_TEX_ANY) { - GLuint unit; - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - if (inputs & VERT_BIT_TEX(unit)) { - _tnl_import_texcoord( ctx, unit, GL_FALSE, GL_FALSE ); - tmp->TexCoord[unit].count = VB->Count; - VB->TexCoordPtr[unit] = &tmp->TexCoord[unit]; - } + if (inputs & _TNL_BIT_COLOR0) { + _tnl_import_color( ctx, 0, 0 ); + tmp->Color.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &tmp->Color; } - } - if (inputs & (VERT_BIT_INDEX | VERT_BIT_FOG | - VERT_BIT_EDGEFLAG | VERT_BIT_COLOR1)) { - if (inputs & VERT_BIT_INDEX) { + if (inputs & _TNL_BIT_INDEX) { _tnl_import_index( ctx, 0, 0 ); tmp->Index.count = VB->Count; - VB->IndexPtr[0] = &tmp->Index; - VB->IndexPtr[1] = 0; + VB->AttribPtr[_TNL_ATTRIB_INDEX] = &tmp->Index; } - if (inputs & VERT_BIT_FOG) { + if (inputs & _TNL_BIT_FOG) { _tnl_import_fogcoord( ctx, 0, 0 ); tmp->FogCoord.count = VB->Count; - VB->FogCoordPtr = &tmp->FogCoord; + VB->AttribPtr[_TNL_ATTRIB_FOG] = &tmp->FogCoord; } - if (inputs & VERT_BIT_EDGEFLAG) { + if (inputs & _TNL_BIT_EDGEFLAG) { _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); - VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data; + VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag; + } + + if (inputs & _TNL_BIT_COLOR1) { + _tnl_import_secondarycolor( ctx, 0, 0 ); + tmp->SecondaryColor.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_COLOR1] = &tmp->SecondaryColor; } - if (inputs & VERT_BIT_COLOR1) { - _tnl_import_secondarycolor( ctx, 0, 0, 0 ); - VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; - VB->SecondaryColorPtr[1] = 0; + + if (inputs & _TNL_BITS_TEX_ANY) { + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (inputs & _TNL_BIT_TEX(i)) { + _tnl_import_texcoord( ctx, i, GL_FALSE, GL_FALSE ); + tmp->TexCoord[i].count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_TEX0 + i] = &tmp->TexCoord[i]; + } + } } } + + + /* These are constant & can be precalculated: + */ + if (inputs & _TNL_BITS_MAT_ANY) { + for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) { + tmp->Attribs[i].count = count; + tmp->Attribs[i].data = (GLfloat (*)[4]) tnl->vtx.current[i]; + tmp->Attribs[i].start = tnl->vtx.current[i]; + tmp->Attribs[i].size = 4; + tmp->Attribs[i].stride = 0; + VB->AttribPtr[i] = &tmp->Attribs[i]; + } + } + + + /* Legacy pointers -- remove one day. + */ + VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS]; + VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]; + VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0]; + VB->ColorPtr[1] = 0; + VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX]; + VB->IndexPtr[1] = 0; + VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1]; + VB->SecondaryColorPtr[1] = 0; + + for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { + VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]; + } + } |