2002-10-29 20:28:36 +00:00
|
|
|
/* $Id: t_array_import.c,v 1.27 2002/10/29 20:29:01 brianp Exp $ */
|
2000-12-26 05:09:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mesa 3-D graphics library
|
2002-01-06 03:54:12 +00:00
|
|
|
* Version: 4.1
|
2000-12-26 05:09:27 +00:00
|
|
|
*
|
2002-01-06 03:54:12 +00:00
|
|
|
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
|
2000-12-26 05:09:27 +00:00
|
|
|
*
|
|
|
|
* 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:
|
2002-10-29 20:28:36 +00:00
|
|
|
* Keith Whitwell <keith@tungstengraphics.com>
|
2000-12-26 05:09:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "glheader.h"
|
|
|
|
#include "context.h"
|
|
|
|
#include "macros.h"
|
2002-10-24 23:57:19 +00:00
|
|
|
#include "imports.h"
|
2000-12-26 05:09:27 +00:00
|
|
|
#include "mmath.h"
|
|
|
|
#include "state.h"
|
|
|
|
#include "mtypes.h"
|
|
|
|
|
|
|
|
#include "array_cache/acache.h"
|
|
|
|
#include "math/m_translate.h"
|
|
|
|
|
|
|
|
#include "t_array_import.h"
|
|
|
|
#include "t_context.h"
|
2001-05-11 08:11:31 +00:00
|
|
|
#include "t_imm_debug.h"
|
2000-12-26 05:09:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void _tnl_import_vertex( GLcontext *ctx,
|
2001-04-28 08:39:17 +00:00
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
2000-12-26 05:09:27 +00:00
|
|
|
{
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
|
2001-03-12 00:48:37 +00:00
|
|
|
tmp = _ac_import_vertex(ctx,
|
2000-12-26 05:09:27 +00:00
|
|
|
GL_FLOAT,
|
|
|
|
stride ? 4*sizeof(GLfloat) : 0,
|
|
|
|
0,
|
2001-03-12 00:48:37 +00:00
|
|
|
writeable,
|
2000-12-26 05:09:27 +00:00
|
|
|
&is_writeable);
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2001-03-07 05:06:11 +00:00
|
|
|
inputs->Obj.data = (GLfloat (*)[4]) tmp->Ptr;
|
|
|
|
inputs->Obj.start = (GLfloat *) tmp->Ptr;
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->Obj.stride = tmp->StrideB;
|
|
|
|
inputs->Obj.size = tmp->Size;
|
|
|
|
inputs->Obj.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE);
|
2000-12-28 22:11:04 +00:00
|
|
|
if (inputs->Obj.stride != 4*sizeof(GLfloat))
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->Obj.flags |= VEC_BAD_STRIDE;
|
|
|
|
if (!is_writeable)
|
|
|
|
inputs->Obj.flags |= VEC_NOT_WRITEABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _tnl_import_normal( GLcontext *ctx,
|
2001-04-28 08:39:17 +00:00
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
2000-12-26 05:09:27 +00:00
|
|
|
{
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
|
2001-03-12 00:48:37 +00:00
|
|
|
tmp = _ac_import_normal(ctx, GL_FLOAT,
|
|
|
|
stride ? 3*sizeof(GLfloat) : 0, writeable,
|
2000-12-26 05:09:27 +00:00
|
|
|
&is_writeable);
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2002-04-19 00:45:50 +00:00
|
|
|
inputs->Normal.data = (GLfloat (*)[4]) tmp->Ptr;
|
2001-03-07 05:06:11 +00:00
|
|
|
inputs->Normal.start = (GLfloat *) tmp->Ptr;
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->Normal.stride = tmp->StrideB;
|
|
|
|
inputs->Normal.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE);
|
2000-12-28 22:11:04 +00:00
|
|
|
if (inputs->Normal.stride != 3*sizeof(GLfloat))
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->Normal.flags |= VEC_BAD_STRIDE;
|
|
|
|
if (!is_writeable)
|
|
|
|
inputs->Normal.flags |= VEC_NOT_WRITEABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void _tnl_import_color( GLcontext *ctx,
|
2001-04-28 08:39:17 +00:00
|
|
|
GLenum type,
|
2000-12-26 05:09:27 +00:00
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
|
|
|
{
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
|
2001-03-12 00:48:37 +00:00
|
|
|
tmp = _ac_import_color(ctx,
|
2001-04-28 08:39:17 +00:00
|
|
|
type,
|
|
|
|
stride ? 4*sizeof(GLfloat) : 0,
|
2000-12-26 05:09:27 +00:00
|
|
|
4,
|
2001-03-12 00:48:37 +00:00
|
|
|
writeable,
|
2000-12-26 05:09:27 +00:00
|
|
|
&is_writeable);
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2001-04-28 08:39:17 +00:00
|
|
|
inputs->Color = *tmp;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void _tnl_import_secondarycolor( GLcontext *ctx,
|
2001-04-28 08:39:17 +00:00
|
|
|
GLenum type,
|
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
2000-12-26 05:09:27 +00:00
|
|
|
{
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
|
2001-04-28 08:39:17 +00:00
|
|
|
tmp = _ac_import_secondarycolor(ctx,
|
|
|
|
type,
|
|
|
|
stride ? 4*sizeof(GLfloat) : 0,
|
2000-12-26 05:09:27 +00:00
|
|
|
4,
|
2001-03-12 00:48:37 +00:00
|
|
|
writeable,
|
2000-12-26 05:09:27 +00:00
|
|
|
&is_writeable);
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2001-04-28 08:39:17 +00:00
|
|
|
inputs->SecondaryColor = *tmp;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void _tnl_import_fogcoord( GLcontext *ctx,
|
2001-04-28 08:39:17 +00:00
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
2000-12-26 05:09:27 +00:00
|
|
|
{
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
|
2001-03-12 00:48:37 +00:00
|
|
|
tmp = _ac_import_fogcoord(ctx, GL_FLOAT,
|
|
|
|
stride ? sizeof(GLfloat) : 0, writeable,
|
2000-12-26 05:09:27 +00:00
|
|
|
&is_writeable);
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2002-01-05 20:51:12 +00:00
|
|
|
inputs->FogCoord.data = (GLfloat (*)[4]) tmp->Ptr;
|
2001-03-07 05:06:11 +00:00
|
|
|
inputs->FogCoord.start = (GLfloat *) tmp->Ptr;
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->FogCoord.stride = tmp->StrideB;
|
|
|
|
inputs->FogCoord.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE);
|
2000-12-28 22:11:04 +00:00
|
|
|
if (inputs->FogCoord.stride != sizeof(GLfloat))
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->FogCoord.flags |= VEC_BAD_STRIDE;
|
|
|
|
if (!is_writeable)
|
|
|
|
inputs->FogCoord.flags |= VEC_NOT_WRITEABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _tnl_import_index( GLcontext *ctx,
|
2001-04-28 08:39:17 +00:00
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
2000-12-26 05:09:27 +00:00
|
|
|
{
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
|
2001-03-12 00:48:37 +00:00
|
|
|
tmp = _ac_import_index(ctx, GL_UNSIGNED_INT,
|
|
|
|
stride ? sizeof(GLuint) : 0, writeable,
|
2000-12-26 05:09:27 +00:00
|
|
|
&is_writeable);
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2001-03-07 05:06:11 +00:00
|
|
|
inputs->Index.data = (GLuint *) tmp->Ptr;
|
|
|
|
inputs->Index.start = (GLuint *) tmp->Ptr;
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->Index.stride = tmp->StrideB;
|
|
|
|
inputs->Index.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE);
|
2000-12-28 22:11:04 +00:00
|
|
|
if (inputs->Index.stride != sizeof(GLuint))
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->Index.flags |= VEC_BAD_STRIDE;
|
|
|
|
if (!is_writeable)
|
|
|
|
inputs->Index.flags |= VEC_NOT_WRITEABLE;
|
|
|
|
}
|
|
|
|
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2000-12-26 05:09:27 +00:00
|
|
|
static void _tnl_import_texcoord( GLcontext *ctx,
|
2002-04-21 20:37:04 +00:00
|
|
|
GLuint unit,
|
2001-04-28 08:39:17 +00:00
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
2000-12-26 05:09:27 +00:00
|
|
|
{
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
|
2002-04-21 20:37:04 +00:00
|
|
|
tmp = _ac_import_texcoord(ctx, unit, GL_FLOAT,
|
|
|
|
stride ? 4 * sizeof(GLfloat) : 0,
|
2000-12-26 05:09:27 +00:00
|
|
|
0,
|
2001-03-12 00:48:37 +00:00
|
|
|
writeable,
|
2000-12-26 05:09:27 +00:00
|
|
|
&is_writeable);
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2002-04-21 20:37:04 +00:00
|
|
|
inputs->TexCoord[unit].data = (GLfloat (*)[4]) tmp->Ptr;
|
|
|
|
inputs->TexCoord[unit].start = (GLfloat *) tmp->Ptr;
|
|
|
|
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;
|
2000-12-26 05:09:27 +00:00
|
|
|
if (!is_writeable)
|
2002-04-21 20:37:04 +00:00
|
|
|
inputs->TexCoord[unit].flags |= VEC_NOT_WRITEABLE;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
2001-03-12 00:48:37 +00:00
|
|
|
|
|
|
|
|
2000-12-26 05:09:27 +00:00
|
|
|
static void _tnl_import_edgeflag( GLcontext *ctx,
|
2001-04-28 08:39:17 +00:00
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
2000-12-26 05:09:27 +00:00
|
|
|
{
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
|
2001-03-12 00:48:37 +00:00
|
|
|
tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE,
|
|
|
|
stride ? sizeof(GLubyte) : 0,
|
|
|
|
0,
|
2000-12-26 05:09:27 +00:00
|
|
|
&is_writeable);
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2001-03-07 05:06:11 +00:00
|
|
|
inputs->EdgeFlag.data = (GLubyte *) tmp->Ptr;
|
|
|
|
inputs->EdgeFlag.start = (GLubyte *) tmp->Ptr;
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->EdgeFlag.stride = tmp->StrideB;
|
|
|
|
inputs->EdgeFlag.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE);
|
2000-12-28 22:11:04 +00:00
|
|
|
if (inputs->EdgeFlag.stride != sizeof(GLubyte))
|
2000-12-26 05:09:27 +00:00
|
|
|
inputs->EdgeFlag.flags |= VEC_BAD_STRIDE;
|
|
|
|
if (!is_writeable)
|
|
|
|
inputs->EdgeFlag.flags |= VEC_NOT_WRITEABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-04-21 20:37:04 +00:00
|
|
|
static void _tnl_import_attrib( GLcontext *ctx,
|
|
|
|
GLuint index,
|
|
|
|
GLboolean writeable,
|
|
|
|
GLboolean stride )
|
|
|
|
{
|
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
|
|
|
struct gl_client_array *tmp;
|
|
|
|
GLboolean is_writeable = 0;
|
|
|
|
|
|
|
|
tmp = _ac_import_attrib(ctx, index, GL_FLOAT,
|
|
|
|
stride ? 4 * sizeof(GLfloat) : 0,
|
|
|
|
4, /* want GLfloat[4] */
|
|
|
|
writeable,
|
|
|
|
&is_writeable);
|
|
|
|
|
|
|
|
inputs->Attribs[index].data = (GLfloat (*)[4]) tmp->Ptr;
|
|
|
|
inputs->Attribs[index].start = (GLfloat *) tmp->Ptr;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
/**
|
|
|
|
* Callback for VB stages that need to improve the quality of arrays
|
2000-12-26 05:09:27 +00:00
|
|
|
* bound to the VB. This is only necessary for client arrays which
|
|
|
|
* have not been transformed at any point in the pipeline.
|
2002-01-22 14:35:16 +00:00
|
|
|
* \param required - bitmask of VERT_*_BIT flags
|
|
|
|
* \param flags - bitmask of VEC_* flags (ex: VEC_NOT_WRITABLE)
|
2000-12-26 05:09:27 +00:00
|
|
|
*/
|
|
|
|
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;
|
2000-12-27 19:57:37 +00:00
|
|
|
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
|
2001-04-28 08:39:17 +00:00
|
|
|
GLuint ca_flags = 0;
|
2000-12-27 19:57:37 +00:00
|
|
|
(void) inputs;
|
2000-12-26 05:09:27 +00:00
|
|
|
|
2001-04-28 08:39:17 +00:00
|
|
|
if (writeable || stride) ca_flags |= CA_CLIENT_DATA;
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if ((required & VERT_BIT_CLIP) && VB->ClipPtr == VB->ObjPtr)
|
|
|
|
required |= VERT_BIT_POS;
|
2000-12-26 05:09:27 +00:00
|
|
|
|
2000-12-28 22:11:04 +00:00
|
|
|
/* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if ((required & VERT_BIT_POS) && (VB->ObjPtr->flags & flags)) {
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT(VB->ObjPtr == &inputs->Obj);
|
|
|
|
_tnl_import_vertex( ctx, writeable, stride );
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->importable_data &= ~(VERT_BIT_POS|VERT_BIT_CLIP);
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if ((required & VERT_BIT_NORMAL) && (VB->NormalPtr->flags & flags)) {
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT(VB->NormalPtr == &inputs->Normal);
|
|
|
|
_tnl_import_normal( ctx, writeable, stride );
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->importable_data &= ~VERT_BIT_NORMAL;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if ((required & VERT_BIT_COLOR0) && (VB->ColorPtr[0]->Flags & ca_flags)) {
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT(VB->ColorPtr[0] == &inputs->Color);
|
2001-04-28 08:39:17 +00:00
|
|
|
_tnl_import_color( ctx, GL_FLOAT, writeable, stride );
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->importable_data &= ~VERT_BIT_COLOR0;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if ((required & VERT_BIT_COLOR1) &&
|
2001-04-28 08:39:17 +00:00
|
|
|
(VB->SecondaryColorPtr[0]->Flags & ca_flags)) {
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT(VB->SecondaryColorPtr[0] == &inputs->SecondaryColor);
|
2001-04-28 08:39:17 +00:00
|
|
|
_tnl_import_secondarycolor( ctx, GL_FLOAT, writeable, stride );
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->importable_data &= ~VERT_BIT_COLOR1;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if ((required & VERT_BIT_FOG)
|
2002-01-06 03:54:12 +00:00
|
|
|
&& (VB->FogCoordPtr->flags & flags)) {
|
|
|
|
ASSERT(VB->FogCoordPtr == &inputs->FogCoord);
|
2000-12-26 05:09:27 +00:00
|
|
|
_tnl_import_fogcoord( ctx, writeable, stride );
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->importable_data &= ~VERT_BIT_FOG;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if ((required & VERT_BIT_INDEX) && (VB->IndexPtr[0]->flags & flags)) {
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT(VB->IndexPtr[0] == &inputs->Index);
|
|
|
|
_tnl_import_index( ctx, writeable, stride );
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->importable_data &= ~VERT_BIT_INDEX;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (required & VERT_BITS_TEX_ANY)
|
2001-03-12 00:48:37 +00:00
|
|
|
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
|
2002-01-22 14:35:16 +00:00
|
|
|
if ((required & VERT_BIT_TEX(i)) && (VB->TexCoordPtr[i]->flags & flags)) {
|
2000-12-26 05:09:27 +00:00
|
|
|
ASSERT(VB->TexCoordPtr[i] == &inputs->TexCoord[i]);
|
|
|
|
_tnl_import_texcoord( ctx, i, writeable, stride );
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->importable_data &= ~VERT_BIT_TEX(i);
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2002-04-21 20:37:04 +00:00
|
|
|
/* XXX not sure what to do here for vertex program arrays */
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2002-06-29 19:48:15 +00:00
|
|
|
/* _mesa_debug(ctx, "%s %d..%d // %d..%d\n", __FUNCTION__, */
|
2001-05-17 11:33:33 +00:00
|
|
|
/* start, count, ctx->Array.LockFirst, ctx->Array.LockCount); */
|
|
|
|
/* _tnl_print_vert_flags(" inputs", inputs); */
|
|
|
|
/* _tnl_print_vert_flags(" _Enabled", ctx->Array._Enabled); */
|
2002-01-22 14:35:16 +00:00
|
|
|
/* _tnl_print_vert_flags(" importable", inputs & VERT_BITS_FIXUP); */
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2000-12-26 05:09:27 +00:00
|
|
|
VB->Count = count - start;
|
|
|
|
VB->FirstClipped = VB->Count;
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->Elts = NULL;
|
|
|
|
VB->MaterialMask = NULL;
|
|
|
|
VB->Material = NULL;
|
|
|
|
VB->Flag = NULL;
|
2001-05-11 08:11:31 +00:00
|
|
|
VB->Primitive = tnl->tmp_primitive;
|
|
|
|
VB->PrimitiveLength = tnl->tmp_primitive_length;
|
|
|
|
VB->import_data = _tnl_upgrade_client_data;
|
2002-01-22 14:35:16 +00:00
|
|
|
VB->importable_data = inputs & VERT_BITS_FIXUP;
|
2001-05-11 08:11:31 +00:00
|
|
|
|
|
|
|
if (ctx->Array.LockCount) {
|
|
|
|
ASSERT(start == (GLint) ctx->Array.LockFirst);
|
|
|
|
ASSERT(count == (GLint) ctx->Array.LockCount);
|
|
|
|
}
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2001-05-11 08:11:31 +00:00
|
|
|
_ac_import_range( ctx, start, count );
|
2000-12-26 05:09:27 +00:00
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (inputs & VERT_BIT_POS) {
|
2001-05-11 08:11:31 +00:00
|
|
|
_tnl_import_vertex( ctx, 0, 0 );
|
|
|
|
tmp->Obj.count = VB->Count;
|
2000-12-26 05:09:27 +00:00
|
|
|
VB->ObjPtr = &tmp->Obj;
|
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (inputs & VERT_BIT_NORMAL) {
|
2001-05-11 08:11:31 +00:00
|
|
|
_tnl_import_normal( ctx, 0, 0 );
|
|
|
|
tmp->Normal.count = VB->Count;
|
2000-12-26 05:09:27 +00:00
|
|
|
VB->NormalPtr = &tmp->Normal;
|
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (inputs & VERT_BIT_COLOR0) {
|
2001-05-11 08:11:31 +00:00
|
|
|
_tnl_import_color( ctx, 0, 0, 0 );
|
2000-12-26 05:09:27 +00:00
|
|
|
VB->ColorPtr[0] = &tmp->Color;
|
|
|
|
VB->ColorPtr[1] = 0;
|
|
|
|
}
|
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (inputs & VERT_BITS_TEX_ANY) {
|
2002-04-21 20:37:04 +00:00
|
|
|
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];
|
2001-05-11 08:11:31 +00:00
|
|
|
}
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
2001-03-12 00:48:37 +00:00
|
|
|
}
|
2000-12-26 05:09:27 +00:00
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (inputs & (VERT_BIT_INDEX | VERT_BIT_FOG |
|
|
|
|
VERT_BIT_EDGEFLAG | VERT_BIT_COLOR1)) {
|
|
|
|
if (inputs & VERT_BIT_INDEX) {
|
2001-05-11 08:11:31 +00:00
|
|
|
_tnl_import_index( ctx, 0, 0 );
|
|
|
|
tmp->Index.count = VB->Count;
|
|
|
|
VB->IndexPtr[0] = &tmp->Index;
|
|
|
|
VB->IndexPtr[1] = 0;
|
|
|
|
}
|
2000-12-26 05:09:27 +00:00
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (inputs & VERT_BIT_FOG) {
|
2001-03-12 00:48:37 +00:00
|
|
|
_tnl_import_fogcoord( ctx, 0, 0 );
|
2000-12-26 05:09:27 +00:00
|
|
|
tmp->FogCoord.count = VB->Count;
|
2002-01-06 03:54:12 +00:00
|
|
|
VB->FogCoordPtr = &tmp->FogCoord;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (inputs & VERT_BIT_EDGEFLAG) {
|
2001-05-11 08:11:31 +00:00
|
|
|
_tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) );
|
|
|
|
VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data;
|
|
|
|
}
|
2001-03-12 00:48:37 +00:00
|
|
|
|
2002-01-22 14:35:16 +00:00
|
|
|
if (inputs & VERT_BIT_COLOR1) {
|
2001-04-28 08:39:17 +00:00
|
|
|
_tnl_import_secondarycolor( ctx, 0, 0, 0 );
|
2001-05-11 08:11:31 +00:00
|
|
|
VB->SecondaryColorPtr[0] = &tmp->SecondaryColor;
|
|
|
|
VB->SecondaryColorPtr[1] = 0;
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-22 14:35:16 +00:00
|
|
|
|
2002-04-21 20:37:04 +00:00
|
|
|
/* XXX not 100% sure this is finished. Keith should probably inspect. */
|
2002-01-22 14:35:16 +00:00
|
|
|
if (ctx->VertexProgram.Enabled) {
|
2002-04-21 20:37:04 +00:00
|
|
|
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];
|
|
|
|
}
|
2002-01-22 14:35:16 +00:00
|
|
|
}
|
2000-12-26 05:09:27 +00:00
|
|
|
}
|