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); */ 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); } _ac_import_range( ctx, start, count ); 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 & 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 & (VERT_BIT_INDEX | VERT_BIT_FOG | VERT_BIT_EDGEFLAG | VERT_BIT_COLOR1)) { if (inputs & VERT_BIT_INDEX) { _tnl_import_index( ctx, 0, 0 ); tmp->Index.count = VB->Count; VB->IndexPtr[0] = &tmp->Index; VB->IndexPtr[1] = 0; } if (inputs & VERT_BIT_FOG) { _tnl_import_fogcoord( ctx, 0, 0 ); tmp->FogCoord.count = VB->Count; VB->FogCoordPtr = &tmp->FogCoord; } if (inputs & VERT_BIT_EDGEFLAG) { _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data; } if (inputs & VERT_BIT_COLOR1) { _tnl_import_secondarycolor( ctx, 0, 0, 0 ); VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; VB->SecondaryColorPtr[1] = 0; } } /* XXX not 100% sure this is finished. Keith should probably inspect. */ if (ctx->VertexProgram.Enabled) { GLuint index; for (index = 0; index < VERT_ATTRIB_MAX; index++) { /* XXX check program->InputsRead to reduce work here */ _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE ); VB->AttribPtr[index] = &tmp->Attribs[index]; } } }
static void bind_inputs( struct gl_context *ctx, const struct gl_client_array *inputs[], GLint count, struct gl_buffer_object **bo, GLuint *nr_bo ) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; GLuint i; /* Map all the VBOs */ for (i = 0; i < VERT_ATTRIB_MAX; i++) { const void *ptr; if (inputs[i]->BufferObj->Name) { if (!inputs[i]->BufferObj->Pointer) { bo[*nr_bo] = inputs[i]->BufferObj; (*nr_bo)++; ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY_ARB, inputs[i]->BufferObj); assert(inputs[i]->BufferObj->Pointer); } ptr = ADD_POINTERS(inputs[i]->BufferObj->Pointer, inputs[i]->Ptr); } else ptr = inputs[i]->Ptr; /* Just make sure the array is floating point, otherwise convert to * temporary storage. * * XXX: remove the GLvector4f type at some stage and just use * client arrays. */ _tnl_import_array(ctx, i, count, inputs[i], ptr); } /* We process only the vertices between min & max index: */ VB->Count = count; /* These should perhaps be part of _TNL_ATTRIB_* */ VB->BackfaceColorPtr = NULL; VB->BackfaceIndexPtr = NULL; VB->BackfaceSecondaryColorPtr = NULL; /* Clipping and drawing code still requires this to be a packed * array of ubytes which can be written into. TODO: Fix and * remove. */ if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) { VB->EdgeFlag = _tnl_import_edgeflag( ctx, VB->AttribPtr[_TNL_ATTRIB_EDGEFLAG], VB->Count ); } else { /* the data previously pointed to by EdgeFlag may have been freed */ VB->EdgeFlag = NULL; } }