diff options
Diffstat (limited to 'mesalib/src/mesa/vbo')
-rw-r--r-- | mesalib/src/mesa/vbo/vbo_context.c | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/vbo/vbo_exec.h | 42 | ||||
-rw-r--r-- | mesalib/src/mesa/vbo/vbo_exec_api.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/vbo/vbo_exec_array.c | 61 | ||||
-rw-r--r-- | mesalib/src/mesa/vbo/vbo_save_draw.c | 3 |
5 files changed, 66 insertions, 53 deletions
diff --git a/mesalib/src/mesa/vbo/vbo_context.c b/mesalib/src/mesa/vbo/vbo_context.c index b2e6bbc12..d83f2fd23 100644 --- a/mesalib/src/mesa/vbo/vbo_context.c +++ b/mesalib/src/mesa/vbo/vbo_context.c @@ -176,17 +176,14 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx ) { GLuint i; - /* When no vertex program, pull in the material attributes in - * the generic range. - */ - for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) + /* identity mapping */ + for (i = 0; i < Elements(vbo->map_vp_none); i++) vbo->map_vp_none[i] = i; + /* map material attribs to generic slots */ for (i = 0; i < NR_MAT_ATTRIBS; i++) vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i; - for (i = NR_MAT_ATTRIBS; i < VERT_ATTRIB_GENERIC_MAX; i++) - vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] = i; - + for (i = 0; i < Elements(vbo->map_vp_arb); i++) vbo->map_vp_arb[i] = i; } diff --git a/mesalib/src/mesa/vbo/vbo_exec.h b/mesalib/src/mesa/vbo/vbo_exec.h index cfed8e86d..f6ede99cd 100644 --- a/mesalib/src/mesa/vbo/vbo_exec.h +++ b/mesalib/src/mesa/vbo/vbo_exec.h @@ -78,12 +78,26 @@ struct vbo_exec_copied_vtx { }; +/** Used to signal when transitioning from one kind of drawing method + * to another. + */ +enum draw_method +{ + DRAW_NONE, /**< Initial value only */ + DRAW_BEGIN_END, + DRAW_DISPLAY_LIST, + DRAW_ARRAYS +}; + + struct vbo_exec_context { struct gl_context *ctx; GLvertexformat vtxfmt; GLvertexformat vtxfmt_noop; + enum draw_method last_draw_method; + struct { struct gl_buffer_object *bufferobj; @@ -122,12 +136,6 @@ struct vbo_exec_context } eval; struct { - /* These just mirror the current arrayobj (todo: make arrayobj - * look like this and remove the mirror): - */ - const struct gl_client_array *legacy_array[VERT_ATTRIB_FF_MAX]; - const struct gl_client_array *generic_array[VERT_ATTRIB_GENERIC_MAX]; - /* Arrays and current values manipulated according to program * mode, etc. These are the attributes as seen by vertex * programs: @@ -164,6 +172,28 @@ void vbo_exec_array_destroy( struct vbo_exec_context *exec ); void vbo_exec_vtx_init( struct vbo_exec_context *exec ); void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ); + +/** + * This is called by glBegin, glDrawArrays and glDrawElements (and + * variations of those calls). When we transition from immediate mode + * drawing to array drawing we need to invalidate the array state. + * + * glBegin/End builds vertex arrays. Those arrays may look identical + * to glDrawArrays arrays except that the position of the elements may + * be different. For example, arrays of (position3v, normal3f) vs. arrays + * of (normal3f, position3f). So we need to make sure we notify drivers + * that arrays may be changing. + */ +static inline void +vbo_draw_method(struct vbo_exec_context *exec, enum draw_method method) +{ + if (exec->last_draw_method != method) { + exec->ctx->NewState |= _NEW_ARRAY; + exec->last_draw_method = method; + } +} + + #if FEATURE_beginend void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ); diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c index 4be016925..cb5f9ae52 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_api.c +++ b/mesalib/src/mesa/vbo/vbo_exec_api.c @@ -701,6 +701,8 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) return; } + vbo_draw_method(exec, DRAW_BEGIN_END); + if (ctx->Driver.PrepareExecBegin) ctx->Driver.PrepareExecBegin(ctx); diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index a6e41e9c5..2db85e2e5 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -332,6 +332,7 @@ print_draw_arrays(struct gl_context *ctx, { struct vbo_context *vbo = vbo_context(ctx); struct vbo_exec_context *exec = &vbo->exec; + struct gl_array_object *arrayObj = ctx->Array.ArrayObj; int i; printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n", @@ -347,7 +348,7 @@ print_draw_arrays(struct gl_context *ctx, exec->array.inputs[i]->Size, stride, /*exec->array.inputs[i]->Enabled,*/ - exec->array.legacy_array[i]->Enabled, + arrayObj->VertexAttrib[VERT_ATTRIB_FF(i)].Enabled, exec->array.inputs[i]->Ptr, bufName); @@ -372,30 +373,6 @@ print_draw_arrays(struct gl_context *ctx, /** - * Bind the VBO executor to the current vertex array object prior - * to drawing. - * - * Just translate the arrayobj into a sane layout. - */ -static void -bind_array_obj(struct gl_context *ctx) -{ - struct vbo_context *vbo = vbo_context(ctx); - struct vbo_exec_context *exec = &vbo->exec; - struct gl_array_object *arrayObj = ctx->Array.ArrayObj; - GLuint i; - - for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) - exec->array.legacy_array[i] = &arrayObj->VertexAttrib[VERT_ATTRIB_FF(i)]; - - for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) { - assert(i < Elements(exec->array.generic_array)); - exec->array.generic_array[i] = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]; - } -} - - -/** * Set the vbo->exec->inputs[] pointers to point to the enabled * vertex arrays. This depends on the current vertex program/shader * being executed because of whether or not generic vertex arrays @@ -408,6 +385,7 @@ recalculate_input_bindings(struct gl_context *ctx) { struct vbo_context *vbo = vbo_context(ctx); struct vbo_exec_context *exec = &vbo->exec; + struct gl_client_array *vertexAttrib = ctx->Array.ArrayObj->VertexAttrib; const struct gl_client_array **inputs = &exec->array.inputs[0]; GLbitfield64 const_inputs = 0x0; GLuint i; @@ -420,8 +398,8 @@ recalculate_input_bindings(struct gl_context *ctx) * are available as per-vertex attributes. */ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) { - if (exec->array.legacy_array[i]->Enabled) - inputs[i] = exec->array.legacy_array[i]; + if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled) + inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)]; else { inputs[i] = &vbo->legacy_currval[i]; const_inputs |= VERT_BIT(i); @@ -457,10 +435,10 @@ recalculate_input_bindings(struct gl_context *ctx) */ for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) { if (i < VERT_ATTRIB_GENERIC_MAX - && exec->array.generic_array[i]->Enabled) - inputs[i] = exec->array.generic_array[i]; - else if (exec->array.legacy_array[i]->Enabled) - inputs[i] = exec->array.legacy_array[i]; + && vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) + inputs[i] = &vertexAttrib[VERT_ATTRIB_GENERIC(i)]; + else if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled) + inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)]; else { inputs[i] = &vbo->legacy_currval[i]; const_inputs |= VERT_BIT_FF(i); @@ -486,18 +464,18 @@ recalculate_input_bindings(struct gl_context *ctx) * generic attributes in the generic slots and materials are not * available as per-vertex attributes. */ - if (exec->array.generic_array[0]->Enabled) - inputs[0] = exec->array.generic_array[0]; - else if (exec->array.legacy_array[0]->Enabled) - inputs[0] = exec->array.legacy_array[0]; + if (vertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) + inputs[0] = &vertexAttrib[VERT_ATTRIB_GENERIC0]; + else if (vertexAttrib[VERT_ATTRIB_POS].Enabled) + inputs[0] = &vertexAttrib[VERT_ATTRIB_POS]; else { inputs[0] = &vbo->legacy_currval[0]; const_inputs |= VERT_BIT_POS; } for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) { - if (exec->array.legacy_array[i]->Enabled) - inputs[i] = exec->array.legacy_array[i]; + if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled) + inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)]; else { inputs[i] = &vbo->legacy_currval[i]; const_inputs |= VERT_BIT_FF(i); @@ -505,8 +483,8 @@ recalculate_input_bindings(struct gl_context *ctx) } for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { - if (exec->array.generic_array[i]->Enabled) - inputs[VERT_ATTRIB_GENERIC(i)] = exec->array.generic_array[i]; + if (vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) + inputs[VERT_ATTRIB_GENERIC(i)] = &vertexAttrib[VERT_ATTRIB_GENERIC(i)]; else { inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->generic_currval[i]; const_inputs |= VERT_BIT_GENERIC(i); @@ -536,7 +514,6 @@ vbo_bind_arrays(struct gl_context *ctx) return; } - bind_array_obj(ctx); recalculate_input_bindings(ctx); ctx->Array.RebindArrays = GL_FALSE; } @@ -558,6 +535,8 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start, vbo_bind_arrays(ctx); + vbo_draw_method(exec, DRAW_ARRAYS); + /* Again... because we may have changed the bitmask of per-vertex varying * attributes. If we regenerate the fixed-function vertex program now * we may be able to prune down the number of vertex attributes which we @@ -773,6 +752,8 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, vbo_bind_arrays( ctx ); + vbo_draw_method(exec, DRAW_ARRAYS); + /* check for dirty state again */ if (ctx->NewState) _mesa_update_state( ctx ); diff --git a/mesalib/src/mesa/vbo/vbo_save_draw.c b/mesalib/src/mesa/vbo/vbo_save_draw.c index fa93ca48f..9f0290561 100644 --- a/mesalib/src/mesa/vbo/vbo_save_draw.c +++ b/mesalib/src/mesa/vbo/vbo_save_draw.c @@ -248,6 +248,7 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) const struct vbo_save_vertex_list *node = (const struct vbo_save_vertex_list *) data; struct vbo_save_context *save = &vbo_context(ctx)->save; + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; FLUSH_CURRENT(ctx, 0); @@ -286,6 +287,8 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data) vbo_bind_vertex_list( ctx, node ); + vbo_draw_method(exec, DRAW_DISPLAY_LIST); + /* Again... */ if (ctx->NewState) |