-/* $Id: ac_import.c,v 1.17 2002/04/21 18:49:19 brianp Exp $ */
+/* $Id: ac_import.c,v 1.18 2002/04/21 20:37:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
static void reset_attrib( GLcontext *ctx, GLuint index )
{
ACcontext *ac = AC_CONTEXT(ctx);
+ GLboolean fallback = GL_FALSE;
+ /*
+ * The 16 NV vertex attribute arrays have top priority. If one of those
+ * is not enabled, look if a corresponding conventional array is enabled.
+ * If nothing else, use the fallback (ctx->Current.Attrib) values.
+ */
if (ctx->Array._Enabled & _NEW_ARRAY_ATTRIB(index)) {
ac->Raw.Attrib[index] = ctx->Array.VertexAttrib[index];
STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start);
}
+ else if (ctx->Array._Enabled & (1 << index)) {
+ /* use conventional vertex array */
+ switch (index) {
+ case VERT_ATTRIB_POS:
+ ac->Raw.Attrib[index] = ctx->Array.Vertex;
+ break;
+ case VERT_ATTRIB_NORMAL:
+ ac->Raw.Attrib[index] = ctx->Array.Normal;
+ break;
+ case VERT_ATTRIB_COLOR0:
+ ac->Raw.Attrib[index] = ctx->Array.Color;
+ break;
+ case VERT_ATTRIB_COLOR1:
+ ac->Raw.Attrib[index] = ctx->Array.SecondaryColor;
+ break;
+ case VERT_ATTRIB_FOG:
+ ac->Raw.Attrib[index] = ctx->Array.FogCoord;
+ break;
+ default:
+ if (index >= VERT_ATTRIB_TEX0 && index <= VERT_ATTRIB_TEX7) {
+ GLuint unit = index - VERT_ATTRIB_TEX0;
+ ac->Raw.Attrib[index] = ctx->Array.TexCoord[unit];
+ }
+ else {
+ /* missing conventional array (vertex weight, for example) */
+ fallback = GL_TRUE;
+ }
+ break;
+ }
+ if (!fallback)
+ STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start);
+ }
else {
+ fallback = GL_TRUE;
+ }
+
+ if (fallback) {
+ /* fallback to ctx->Current.Attrib values */
ac->Raw.Attrib[index] = ac->Fallback.Attrib[index];
if (ctx->Current.Attrib[index][3] != 1.0)
/* Can we keep the existing version?
*/
- if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index))
+ if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index)) {
reset_attrib( ctx, index );
+ }
+ else if (ac->NewArrayState & (1 << index)) {
+ /* Also need to check conventional attributes */
+ reset_attrib( ctx, index );
+ }
/* Is the request impossible?
*/
if (reqsize != 0 && ac->Raw.Attrib[index].Size > (GLint) reqsize)
- return 0;
+ return NULL;
/* Do we need to pull in a copy of the client data:
*/
-/* $Id: t_array_import.c,v 1.23 2002/04/19 00:45:50 brianp Exp $ */
+/* $Id: t_array_import.c,v 1.24 2002/04/21 20:37:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
static void _tnl_import_texcoord( GLcontext *ctx,
- GLuint i,
+ GLuint unit,
GLboolean writeable,
GLboolean stride )
{
struct gl_client_array *tmp;
GLboolean is_writeable = 0;
- tmp = _ac_import_texcoord(ctx, i, GL_FLOAT,
- stride ? 4*sizeof(GLfloat) : 0,
+ tmp = _ac_import_texcoord(ctx, unit, GL_FLOAT,
+ stride ? 4 * sizeof(GLfloat) : 0,
0,
writeable,
&is_writeable);
- inputs->TexCoord[i].data = (GLfloat (*)[4]) tmp->Ptr;
- inputs->TexCoord[i].start = (GLfloat *) tmp->Ptr;
- inputs->TexCoord[i].stride = tmp->StrideB;
- inputs->TexCoord[i].size = tmp->Size;
- inputs->TexCoord[i].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE);
- if (inputs->TexCoord[i].stride != 4*sizeof(GLfloat))
- inputs->TexCoord[i].flags |= VEC_BAD_STRIDE;
+ 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;
if (!is_writeable)
- inputs->TexCoord[i].flags |= VEC_NOT_WRITEABLE;
+ inputs->TexCoord[unit].flags |= VEC_NOT_WRITEABLE;
}
+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;
+}
+
+
+
/**
* Callback for VB stages that need to improve the quality of arrays
* bound to the VB. This is only necessary for client arrays which
VB->importable_data &= ~VERT_BIT_TEX(i);
}
+ /* XXX not sure what to do here for vertex program arrays */
}
struct vertex_buffer *VB = &tnl->vb;
GLuint inputs = tnl->pipeline.inputs;
struct vertex_arrays *tmp = &tnl->array_inputs;
- GLuint i;
/* fprintf(stderr, "%s %d..%d // %d..%d\n", __FUNCTION__, */
/* start, count, ctx->Array.LockFirst, ctx->Array.LockCount); */
}
if (inputs & VERT_BITS_TEX_ANY) {
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- if (inputs & VERT_BIT_TEX(i)) {
- _tnl_import_texcoord( ctx, i, 0, 0 );
- tmp->TexCoord[i].count = VB->Count;
- VB->TexCoordPtr[i] = &tmp->TexCoord[i];
+ 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];
}
}
}
}
}
+ /* XXX not 100% sure this is finished. Keith should probably inspect. */
if (ctx->VertexProgram.Enabled) {
- /* XXX lots of work to do here */
-
- VB->AttribPtr[VERT_ATTRIB_POS] = VB->ObjPtr;
- /*
- printf("bind vp arrays!\n");
- printf(" data = %p\n", VB->ObjPtr->data);
- printf(" stride = %d\n", VB->ObjPtr->stride);
- printf(" size = %d\n", VB->ObjPtr->size);
- */
-
- VB->AttribPtr[VERT_ATTRIB_NORMAL] = VB->NormalPtr;
+ 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];
+ }
}
-
}
-
-
-/* $Id: t_vb_program.c,v 1.11 2002/04/04 18:25:40 kschultz Exp $ */
+/* $Id: t_vb_program.c,v 1.12 2002/04/21 20:37:04 brianp Exp $ */
/*
* Mesa 3-D graphics library
VB->AttribPtr[2]->data[i][3]);
#endif
- /* XXXX
- * We have to deal with stride!=16 bytes, size!=4, etc in these loops!!!
- */
-
/* load the input attribute registers */
if (VB->Flag) {
/* the traditional glBegin/glVertex/glEnd case */
else {
/* the vertex array case */
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- const GLubyte *ptr = (const GLubyte *) VB->AttribPtr[attr]->data;
- const GLint stride = VB->AttribPtr[attr]->stride;
- const GLfloat *data = (GLfloat *) (ptr + stride * i);
- const GLint size = VB->AttribPtr[attr]->size;
- COPY_4V(machine->Registers[VP_INPUT_REG_START + attr], data);
- if (size == 3)
- machine->Registers[VP_INPUT_REG_START + attr][3] = 1.0;
+ if (program->InputsRead & (1 << attr)) {
+ const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data;
+ const GLuint stride = VB->AttribPtr[attr]->stride;
+ const GLfloat *data = (GLfloat *) (ptr + stride * i);
+ COPY_4V(machine->Registers[VP_INPUT_REG_START + attr], data);
+ /*ASSERT(VB->AttribPtr[attr]->size == 4);*/
+ ASSERT(stride == 4 * sizeof(GLfloat) || stride == 0);
+ }
}
}
stage->active = ctx->VertexProgram.Enabled;
if (stage->active) {
- /* XXX what do we need here??? */
- /*
- GLbitfield vpInput = ctx->VertexProgram.Current->InputsRead;
- */
+ /* XXX what do we need here???
+ *
+ * I think that:
+ * stage->inputs = ctx->VertexProgram.Current->InputsRead;
+ * would be correct, and something similar for the outputs.
+ */
#if 000
if (stage->privatePtr)