{
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;
}
};
+/** 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;
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 );
return;
}
+ vbo_draw_method(exec, DRAW_BEGIN_END);
+
if (ctx->Driver.PrepareExecBegin)
ctx->Driver.PrepareExecBegin(ctx);
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
vbo_bind_arrays( ctx );
+ vbo_draw_method(exec, DRAW_ARRAYS);
+
/* check for dirty state again */
if (ctx->NewState)
_mesa_update_state( ctx );
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);
vbo_bind_vertex_list( ctx, node );
+ vbo_draw_method(exec, DRAW_DISPLAY_LIST);
+
/* Again...
*/
if (ctx->NewState)