void vbo_exec_BeginVertices( GLcontext *ctx ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; if (0) _mesa_printf("%s\n", __FUNCTION__); vbo_exec_vtx_map( exec ); assert((exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0); exec->ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; }
/** * Called upon first glVertex, glColor, glTexCoord, etc. */ void vbo_exec_BeginVertices( struct gl_context *ctx ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; vbo_exec_vtx_map( exec ); assert((ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0); assert(exec->begin_vertices_flags); ctx->Driver.NeedFlush |= exec->begin_vertices_flags; }
/** * Execute the buffer and save copied verts. * \param keep_unmapped if true, leave the VBO unmapped when we're done. */ void vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped) { if (0) vbo_exec_debug_verts(exec); if (exec->vtx.prim_count && exec->vtx.vert_count) { exec->vtx.copied.nr = vbo_copy_vertices(exec); if (exec->vtx.copied.nr != exec->vtx.vert_count) { struct gl_context *ctx = exec->ctx; /* Prepare and set the exec draws internal VAO for drawing. */ vbo_exec_bind_arrays(ctx); if (ctx->NewState) _mesa_update_state(ctx); vbo_exec_vtx_unmap(exec); assert(ctx->NewState == 0); if (0) printf("%s %d %d\n", __func__, exec->vtx.prim_count, exec->vtx.vert_count); ctx->Driver.Draw(ctx, exec->vtx.prim, exec->vtx.prim_count, NULL, GL_TRUE, 0, exec->vtx.vert_count - 1, NULL, 0, NULL); /* Get new storage -- unless asked not to. */ if (!keepUnmapped) vbo_exec_vtx_map(exec); } } /* May have to unmap explicitly if we didn't draw: */ if (keepUnmapped && exec->vtx.buffer_map) { vbo_exec_vtx_unmap(exec); } if (keepUnmapped || exec->vtx.vertex_size == 0) exec->vtx.max_vert = 0; else exec->vtx.max_vert = vbo_compute_max_verts(exec); exec->vtx.buffer_ptr = exec->vtx.buffer_map; exec->vtx.prim_count = 0; exec->vtx.vert_count = 0; }
/** * Execute the buffer and save copied verts. * \param keep_unmapped if true, leave the VBO unmapped when we're done. */ void vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped) { if (0) vbo_exec_debug_verts( exec ); if (exec->vtx.prim_count && exec->vtx.vert_count) { exec->vtx.copied.nr = vbo_copy_vertices( exec ); if (exec->vtx.copied.nr != exec->vtx.vert_count) { struct gl_context *ctx = exec->ctx; /* Before the update_state() as this may raise _NEW_ARRAY * from _mesa_set_varying_vp_inputs(). */ vbo_exec_bind_arrays( ctx ); if (ctx->NewState) _mesa_update_state( ctx ); if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { vbo_exec_vtx_unmap( exec ); } if (0) printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count, exec->vtx.vert_count); vbo_context(ctx)->draw_prims( ctx, exec->vtx.inputs, exec->vtx.prim, exec->vtx.prim_count, NULL, GL_TRUE, 0, exec->vtx.vert_count - 1, NULL); /* If using a real VBO, get new storage -- unless asked not to. */ if (_mesa_is_bufferobj(exec->vtx.bufferobj) && !keepUnmapped) { vbo_exec_vtx_map( exec ); } } } /* May have to unmap explicitly if we didn't draw: */ if (keepUnmapped && _mesa_is_bufferobj(exec->vtx.bufferobj) && exec->vtx.buffer_map) { vbo_exec_vtx_unmap( exec ); } if (keepUnmapped || exec->vtx.vertex_size == 0) exec->vtx.max_vert = 0; else exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / (exec->vtx.vertex_size * sizeof(GLfloat))); exec->vtx.buffer_ptr = exec->vtx.buffer_map; exec->vtx.prim_count = 0; exec->vtx.vert_count = 0; }