diff options
author | Brian Paul <[email protected]> | 2002-04-21 20:37:04 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-04-21 20:37:04 +0000 |
commit | 12bab63f09975504c20a5dc9b9831a8072c43506 (patch) | |
tree | e1bb3a48e6a65cf6c563444ad12da5317b79d90b /src/mesa/tnl | |
parent | f3781eaafa54d1e4fef0de427b294c02257a3c4d (diff) |
Vertex program attribute arrays seem to work now. This includes fallbacks
to the conventional arrays when attribute arrays aren't enabled.
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 86 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_program.c | 31 |
2 files changed, 69 insertions, 48 deletions
diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 50ef1c86e30..082ae4ad3ca 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -1,4 +1,4 @@ -/* $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 @@ -177,7 +177,7 @@ static void _tnl_import_index( GLcontext *ctx, static void _tnl_import_texcoord( GLcontext *ctx, - GLuint i, + GLuint unit, GLboolean writeable, GLboolean stride ) { @@ -185,21 +185,21 @@ static void _tnl_import_texcoord( GLcontext *ctx, 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; } @@ -228,6 +228,34 @@ static void _tnl_import_edgeflag( GLcontext *ctx, +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 @@ -300,6 +328,7 @@ static void _tnl_upgrade_client_data( GLcontext *ctx, VB->importable_data &= ~VERT_BIT_TEX(i); } + /* XXX not sure what to do here for vertex program arrays */ } @@ -310,7 +339,6 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) 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); */ @@ -355,11 +383,12 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) } 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]; } } } @@ -391,20 +420,13 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) } } + /* 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]; + } } - } - - diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index fea8c11f2b7..d89d006d4f6 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -1,4 +1,4 @@ -/* $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 @@ -182,10 +182,6 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) 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 */ @@ -199,13 +195,14 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) 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); + } } } @@ -406,10 +403,12 @@ static void check_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) 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) |