summaryrefslogtreecommitdiff
path: root/src/mesa/vbo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r--src/mesa/vbo/vbo.h13
-rw-r--r--src/mesa/vbo/vbo_attrib_tmp.h46
-rw-r--r--src/mesa/vbo/vbo_context.c1
-rw-r--r--src/mesa/vbo/vbo_context.h1
-rw-r--r--src/mesa/vbo/vbo_exec.h14
-rw-r--r--src/mesa/vbo/vbo_exec_api.c212
-rw-r--r--src/mesa/vbo/vbo_exec_array.c81
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c27
-rw-r--r--src/mesa/vbo/vbo_save.c1
-rw-r--r--src/mesa/vbo/vbo_save.h5
-rw-r--r--src/mesa/vbo/vbo_save_api.c63
-rw-r--r--src/mesa/vbo/vbo_save_draw.c2
-rw-r--r--src/mesa/vbo/vbo_save_loopback.c1
-rw-r--r--src/mesa/vbo/vbo_split_copy.c1
-rw-r--r--src/mesa/vbo/vbo_split_inplace.c2
15 files changed, 305 insertions, 165 deletions
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index c1406b250a..26c3d4e0a7 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -32,15 +32,19 @@
#ifndef _VBO_H
#define _VBO_H
-#include "main/mtypes.h"
+#include "main/glheader.h"
+
+struct gl_client_array;
+struct gl_context;
struct _mesa_prim {
- GLuint mode:8;
+ GLuint mode:8; /**< GL_POINTS, GL_LINES, GL_QUAD_STRIP, etc */
GLuint indexed:1;
GLuint begin:1;
GLuint end:1;
GLuint weak:1;
- GLuint pad:20;
+ GLuint no_current_update:1;
+ GLuint pad:19;
GLuint start;
GLuint count;
@@ -123,9 +127,12 @@ vbo_get_minmax_index(struct gl_context *ctx, const struct _mesa_prim *prim,
void vbo_use_buffer_objects(struct gl_context *ctx);
+void vbo_always_unmap_buffers(struct gl_context *ctx);
void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
+void vbo_check_buffers_are_unmapped(struct gl_context *ctx);
+
void GLAPIENTRY
_es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index 3c235accf3..c793ce0dc3 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -341,7 +341,7 @@ TAG(VertexAttrib1fARB)(GLuint index, GLfloat x)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR1F(VBO_ATTRIB_GENERIC0 + index, x);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -353,7 +353,7 @@ TAG(VertexAttrib1fvARB)(GLuint index, const GLfloat * v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR1FV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -365,7 +365,7 @@ TAG(VertexAttrib2fARB)(GLuint index, GLfloat x, GLfloat y)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR2F(VBO_ATTRIB_GENERIC0 + index, x, y);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -377,7 +377,7 @@ TAG(VertexAttrib2fvARB)(GLuint index, const GLfloat * v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR2FV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -389,7 +389,7 @@ TAG(VertexAttrib3fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR3F(VBO_ATTRIB_GENERIC0 + index, x, y, z);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -401,7 +401,7 @@ TAG(VertexAttrib3fvARB)(GLuint index, const GLfloat * v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR3FV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -413,7 +413,7 @@ TAG(VertexAttrib4fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR4F(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -425,7 +425,7 @@ TAG(VertexAttrib4fvARB)(GLuint index, const GLfloat * v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR4FV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
@@ -442,7 +442,7 @@ TAG(VertexAttribI1i)(GLuint index, GLint x)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR1I(VBO_ATTRIB_GENERIC0 + index, x);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -454,7 +454,7 @@ TAG(VertexAttribI2i)(GLuint index, GLint x, GLint y)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR2I(VBO_ATTRIB_GENERIC0 + index, x, y);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -466,7 +466,7 @@ TAG(VertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR3I(VBO_ATTRIB_GENERIC0 + index, x, y, z);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -478,7 +478,7 @@ TAG(VertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR4I(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -490,7 +490,7 @@ TAG(VertexAttribI2iv)(GLuint index, const GLint *v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR2IV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -502,7 +502,7 @@ TAG(VertexAttribI3iv)(GLuint index, const GLint *v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR3IV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -514,7 +514,7 @@ TAG(VertexAttribI4iv)(GLuint index, const GLint *v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR4IV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
@@ -531,7 +531,7 @@ TAG(VertexAttribI1ui)(GLuint index, GLuint x)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR1UI(VBO_ATTRIB_GENERIC0 + index, x);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -543,7 +543,7 @@ TAG(VertexAttribI2ui)(GLuint index, GLuint x, GLuint y)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR2UI(VBO_ATTRIB_GENERIC0 + index, x, y);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -555,7 +555,7 @@ TAG(VertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR3UI(VBO_ATTRIB_GENERIC0 + index, x, y, z);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -567,7 +567,7 @@ TAG(VertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR4UI(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -579,7 +579,7 @@ TAG(VertexAttribI2uiv)(GLuint index, const GLuint *v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR2UIV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -591,7 +591,7 @@ TAG(VertexAttribI3uiv)(GLuint index, const GLuint *v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR3UIV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
static void GLAPIENTRY
@@ -603,7 +603,7 @@ TAG(VertexAttribI4uiv)(GLuint index, const GLuint *v)
else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR4UIV(VBO_ATTRIB_GENERIC0 + index, v);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
@@ -720,7 +720,7 @@ TAG(Materialfv)(GLenum face, GLenum pname,
MAT(VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params);
break;
default:
- ERROR();
+ ERROR(GL_INVALID_ENUM);
return;
}
}
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 9992cc3473..6656ed8981 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -209,7 +209,6 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx )
void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state )
{
- _ae_invalidate_state(ctx, new_state);
vbo_exec_invalidate_state(ctx, new_state);
}
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
index 8d6f2a7ce6..2ded6ccbff 100644
--- a/src/mesa/vbo/vbo_context.h
+++ b/src/mesa/vbo/vbo_context.h
@@ -51,6 +51,7 @@
#ifndef _VBO_CONTEXT_H
#define _VBO_CONTEXT_H
+#include "main/mfeatures.h"
#include "vbo.h"
#include "vbo_attrib.h"
#include "vbo_exec.h"
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index 47e51f09c9..d52a557e03 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -34,18 +34,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __VBO_EXEC_H__
#define __VBO_EXEC_H__
+#include "main/mfeatures.h"
#include "main/mtypes.h"
#include "vbo.h"
#include "vbo_attrib.h"
+/**
+ * Max number of primitives (number of glBegin/End pairs) per VBO.
+ */
#define VBO_MAX_PRIM 64
-/* Wierd implementation stuff:
+
+/**
+ * Size of the VBO to use for glBegin/glVertex/glEnd-style rendering.
*/
#define VBO_VERT_BUFFER_SIZE (1024*64) /* bytes */
-#define VBO_MAX_ATTR_CODEGEN 16
-#define ERROR_ATTRIB 16
/** Current vertex program mode */
@@ -139,6 +143,9 @@ struct vbo_exec_context
const struct gl_client_array *inputs[VERT_ATTRIB_MAX];
} array;
+ /* Which flags to set in vbo_exec_BeginVertices() */
+ GLbitfield begin_vertices_flags;
+
#ifdef DEBUG
GLint flush_call_depth;
#endif
@@ -151,7 +158,6 @@ struct vbo_exec_context
void vbo_exec_init( struct gl_context *ctx );
void vbo_exec_destroy( struct gl_context *ctx );
void vbo_exec_invalidate_state( struct gl_context *ctx, GLuint new_state );
-void vbo_exec_FlushVertices_internal( struct gl_context *ctx, GLboolean unmap );
void vbo_exec_BeginVertices( struct gl_context *ctx );
void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags );
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index fb981ccc3b..fcd544de76 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -34,6 +34,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "main/bufferobj.h"
#include "main/context.h"
#include "main/macros.h"
+#include "main/mfeatures.h"
#include "main/vtxfmt.h"
#include "main/dlist.h"
#include "main/eval.h"
@@ -158,8 +159,7 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec )
exec->vtx.attrsz[i],
exec->vtx.attrptr[i]);
- if (memcmp(current, tmp, sizeof(tmp)) != 0)
- {
+ if (memcmp(current, tmp, sizeof(tmp)) != 0) {
memcpy(current, tmp, sizeof(tmp));
/* Given that we explicitly state size here, there is no need
@@ -191,14 +191,18 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec )
}
-static void vbo_exec_copy_from_current( struct vbo_exec_context *exec )
+/**
+ * Copy current vertex attribute values into the current vertex.
+ */
+static void
+vbo_exec_copy_from_current(struct vbo_exec_context *exec)
{
struct gl_context *ctx = exec->ctx;
struct vbo_context *vbo = vbo_context(ctx);
GLint i;
- for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) {
- const GLfloat *current = (GLfloat *)vbo->currval[i].Ptr;
+ for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) {
+ const GLfloat *current = (GLfloat *) vbo->currval[i].Ptr;
switch (exec->vtx.attrsz[i]) {
case 4: exec->vtx.attrptr[i][3] = current[3];
case 3: exec->vtx.attrptr[i][2] = current[2];
@@ -212,17 +216,21 @@ static void vbo_exec_copy_from_current( struct vbo_exec_context *exec )
/**
* Flush existing data, set new attrib size, replay copied vertices.
+ * This is called when we transition from a small vertex attribute size
+ * to a larger one. Ex: glTexCoord2f -> glTexCoord4f.
+ * We need to go back over the previous 2-component texcoords and insert
+ * zero and one values.
*/
-static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec,
- GLuint attr,
- GLuint newsz )
+static void
+vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec,
+ GLuint attr, GLuint newSize )
{
struct gl_context *ctx = exec->ctx;
struct vbo_context *vbo = vbo_context(ctx);
- GLint lastcount = exec->vtx.vert_count;
+ const GLint lastcount = exec->vtx.vert_count;
GLfloat *old_attrptr[VBO_ATTRIB_MAX];
- GLuint old_vtx_size = exec->vtx.vertex_size;
- GLuint oldsz = exec->vtx.attrsz[attr];
+ const GLuint old_vtx_size = exec->vtx.vertex_size; /* floats per vertex */
+ const GLuint oldSize = exec->vtx.attrsz[attr];
GLuint i;
/* Run pipeline on current vertices, copy wrapped vertices
@@ -238,7 +246,7 @@ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec,
memcpy(old_attrptr, exec->vtx.attrptr, sizeof(old_attrptr));
}
- if (unlikely(oldsz)) {
+ if (unlikely(oldSize)) {
/* Do a COPY_TO_CURRENT to ensure back-copying works for the
* case when the attribute already exists in the vertex and is
* having its size increased.
@@ -250,21 +258,21 @@ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec,
* begin/end so that they don't bloat the vertices.
*/
if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END &&
- !oldsz && lastcount > 8 && exec->vtx.vertex_size) {
+ !oldSize && lastcount > 8 && exec->vtx.vertex_size) {
vbo_exec_copy_to_current( exec );
reset_attrfv( exec );
}
/* Fix up sizes:
*/
- exec->vtx.attrsz[attr] = newsz;
- exec->vtx.vertex_size += newsz - oldsz;
+ exec->vtx.attrsz[attr] = newSize;
+ exec->vtx.vertex_size += newSize - oldSize;
exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) /
(exec->vtx.vertex_size * sizeof(GLfloat)));
exec->vtx.vert_count = 0;
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
- if (unlikely(oldsz)) {
+ if (unlikely(oldSize)) {
/* Size changed, recalculate all the attrptr[] values
*/
GLfloat *tmp = exec->vtx.vertex;
@@ -282,11 +290,11 @@ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec,
* values.
*/
vbo_exec_copy_from_current( exec );
-
- } else {
+ }
+ else {
/* Just have to append the new attribute at the end */
exec->vtx.attrptr[attr] = exec->vtx.vertex +
- exec->vtx.vertex_size - newsz;
+ exec->vtx.vertex_size - newSize;
}
/* Replay stored vertices to translate them
@@ -310,10 +318,10 @@ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec,
GLint new_offset = exec->vtx.attrptr[j] - exec->vtx.vertex;
if (j == attr) {
- if (oldsz) {
+ if (oldSize) {
GLfloat tmp[4];
- COPY_CLEAN_4V(tmp, oldsz, data + old_offset);
- COPY_SZ_4V(dest + new_offset, newsz, tmp);
+ COPY_CLEAN_4V(tmp, oldSize, data + old_offset);
+ COPY_SZ_4V(dest + new_offset, newSize, tmp);
} else {
GLfloat *current = (GLfloat *)vbo->currval[j].Ptr;
COPY_SZ_4V(dest + new_offset, sz, current);
@@ -336,74 +344,86 @@ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec,
}
-static void vbo_exec_fixup_vertex( struct gl_context *ctx,
- GLuint attr, GLuint sz )
+/**
+ * This is when a vertex attribute transitions to a different size.
+ * For example, we saw a bunch of glTexCoord2f() calls and now we got a
+ * glTexCoord4f() call. We promote the array from size=2 to size=4.
+ */
+static void
+vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize)
{
struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- int i;
- if (sz > exec->vtx.attrsz[attr]) {
+ if (newSize > exec->vtx.attrsz[attr]) {
/* New size is larger. Need to flush existing vertices and get
* an enlarged vertex format.
*/
- vbo_exec_wrap_upgrade_vertex( exec, attr, sz );
+ vbo_exec_wrap_upgrade_vertex( exec, attr, newSize );
}
- else if (sz < exec->vtx.active_sz[attr]) {
+ else if (newSize < exec->vtx.active_sz[attr]) {
static const GLfloat id[4] = { 0, 0, 0, 1 };
+ GLuint i;
/* New size is smaller - just need to fill in some
* zeros. Don't need to flush or wrap.
*/
- for (i = sz ; i <= exec->vtx.attrsz[attr] ; i++)
+ for (i = newSize; i <= exec->vtx.attrsz[attr]; i++)
exec->vtx.attrptr[attr][i-1] = id[i-1];
}
- exec->vtx.active_sz[attr] = sz;
+ exec->vtx.active_sz[attr] = newSize;
/* Does setting NeedFlush belong here? Necessitates resetting
* vtxfmt on each flush (otherwise flags won't get reset
* afterwards).
*/
if (attr == 0)
- exec->ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
}
-/*
+/**
+ * This macro is used to implement all the glVertex, glColor, glTexCoord,
+ * glVertexAttrib, etc functions.
*/
-#define ATTR( A, N, V0, V1, V2, V3 ) \
-do { \
- struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \
+#define ATTR( A, N, V0, V1, V2, V3 ) \
+do { \
+ struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \
\
- if (unlikely(!(exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT))) \
- ctx->Driver.BeginVertices( ctx ); \
+ if (unlikely(!(ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT))) \
+ ctx->Driver.BeginVertices( ctx ); \
+ \
if (unlikely(exec->vtx.active_sz[A] != N)) \
vbo_exec_fixup_vertex(ctx, A, N); \
\
- { \
- GLfloat *dest = exec->vtx.attrptr[A]; \
- if (N>0) dest[0] = V0; \
- if (N>1) dest[1] = V1; \
- if (N>2) dest[2] = V2; \
- if (N>3) dest[3] = V3; \
- } \
- \
- if ((A) == 0) { \
- GLuint i; \
- \
- for (i = 0; i < exec->vtx.vertex_size; i++) \
- exec->vtx.buffer_ptr[i] = exec->vtx.vertex[i]; \
- \
+ { \
+ GLfloat *dest = exec->vtx.attrptr[A]; \
+ if (N>0) dest[0] = V0; \
+ if (N>1) dest[1] = V1; \
+ if (N>2) dest[2] = V2; \
+ if (N>3) dest[3] = V3; \
+ } \
+ \
+ if ((A) == 0) { \
+ /* This is a glVertex call */ \
+ GLuint i; \
+ \
+ for (i = 0; i < exec->vtx.vertex_size; i++) \
+ exec->vtx.buffer_ptr[i] = exec->vtx.vertex[i]; \
+ \
exec->vtx.buffer_ptr += exec->vtx.vertex_size; \
- exec->ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; \
- \
- if (++exec->vtx.vert_count >= exec->vtx.max_vert) \
- vbo_exec_vtx_wrap( exec ); \
- } \
+ \
+ /* Set FLUSH_STORED_VERTICES to indicate that there's now */ \
+ /* something to draw (not just updating a color or texcoord).*/ \
+ ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; \
+ \
+ if (++exec->vtx.vert_count >= exec->vtx.max_vert) \
+ vbo_exec_vtx_wrap( exec ); \
+ } \
} while (0)
-#define ERROR() _mesa_error( ctx, GL_INVALID_ENUM, __FUNCTION__ )
+#define ERROR(err) _mesa_error( ctx, err, __FUNCTION__ )
#define TAG(x) vbo_##x
#include "vbo_attrib_tmp.h"
@@ -513,6 +533,24 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j )
/**
+ * Flush (draw) vertices.
+ * \param unmap - leave VBO unmapped after flushing?
+ */
+static void
+vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec, GLboolean unmap)
+{
+ if (exec->vtx.vert_count || unmap) {
+ vbo_exec_vtx_flush( exec, unmap );
+ }
+
+ if (exec->vtx.vertex_size) {
+ vbo_exec_copy_to_current( exec );
+ reset_attrfv( exec );
+ }
+}
+
+
+/**
* Called via glBegin.
*/
static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
@@ -538,7 +576,7 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode )
* begin/end pairs.
*/
if (exec->vtx.vertex_size && !exec->vtx.attrsz[0])
- vbo_exec_FlushVertices_internal( ctx, GL_FALSE );
+ vbo_exec_FlushVertices_internal(exec, GL_FALSE);
i = exec->vtx.prim_count++;
exec->vtx.prim[i].mode = mode;
@@ -801,6 +839,19 @@ void vbo_use_buffer_objects(struct gl_context *ctx)
}
+/**
+ * If this function is called, all VBO buffers will be unmapped when
+ * we flush.
+ * Otherwise, if a simple command like glColor3f() is called and we flush,
+ * the current VBO may be left mapped.
+ */
+void
+vbo_always_unmap_buffers(struct gl_context *ctx)
+{
+ struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
+ exec->begin_vertices_flags |= FLUSH_STORED_VERTICES;
+}
+
void vbo_exec_vtx_init( struct vbo_exec_context *exec )
{
@@ -824,7 +875,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
/* Hook our functions into the dispatch table.
*/
- _mesa_install_exec_vtxfmt( exec->ctx, &exec->vtxfmt );
+ _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt );
for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) {
ASSERT(i < Elements(exec->vtx.attrsz));
@@ -856,6 +907,8 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
}
exec->vtx.vertex_size = 0;
+
+ exec->begin_vertices_flags = FLUSH_UPDATE_CURRENT;
}
@@ -893,32 +946,25 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec )
_mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
}
+
+/**
+ * Called upon first glVertex, glColor, glTexCoord, etc.
+ */
void vbo_exec_BeginVertices( struct gl_context *ctx )
{
struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- if (0) 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;
-}
-
-void vbo_exec_FlushVertices_internal( struct gl_context *ctx, GLboolean unmap )
-{
- struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
+ vbo_exec_vtx_map( exec );
- if (exec->vtx.vert_count || unmap) {
- vbo_exec_vtx_flush( exec, unmap );
- }
+ assert((ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0);
+ assert(exec->begin_vertices_flags);
- if (exec->vtx.vertex_size) {
- vbo_exec_copy_to_current( exec );
- reset_attrfv( exec );
- }
+ ctx->Driver.NeedFlush |= exec->begin_vertices_flags;
}
/**
+ * Called via ctx->Driver.FlushVertices()
* \param flags bitmask of FLUSH_STORED_VERTICES, FLUSH_UPDATE_CURRENT
*/
void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags )
@@ -931,10 +977,8 @@ void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags )
assert(exec->flush_call_depth == 1);
#endif
- if (0) printf("%s\n", __FUNCTION__);
-
- if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
- if (0) printf("%s - inside begin/end\n", __FUNCTION__);
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
+ /* We've had glBegin but not glEnd! */
#ifdef DEBUG
exec->flush_call_depth--;
assert(exec->flush_call_depth == 0);
@@ -942,14 +986,12 @@ void vbo_exec_FlushVertices( struct gl_context *ctx, GLuint flags )
return;
}
- vbo_exec_FlushVertices_internal( ctx, GL_TRUE );
+ /* Flush (draw), and make sure VBO is left unmapped when done */
+ vbo_exec_FlushVertices_internal(exec, GL_TRUE);
/* Need to do this to ensure BeginVertices gets called again:
*/
- if (exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)
- exec->ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
-
- exec->ctx->Driver.NeedFlush &= ~flags;
+ ctx->Driver.NeedFlush &= ~(FLUSH_UPDATE_CURRENT | flags);
#ifdef DEBUG
exec->flush_call_depth--;
@@ -1020,7 +1062,7 @@ VertexAttrib4f_nopos(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR(VBO_ATTRIB_GENERIC0 + index, 4, x, y, z, w);
else
- ERROR();
+ ERROR(GL_INVALID_VALUE);
}
void GLAPIENTRY
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index dd36cc32a7..98d6badc47 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -39,6 +39,44 @@
/**
+ * All vertex buffers should be in an unmapped state when we're about
+ * to draw. This debug function checks that.
+ */
+static void
+check_buffers_are_unmapped(const struct gl_client_array **inputs)
+{
+#ifdef DEBUG
+ GLuint i;
+
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ if (inputs[i]) {
+ struct gl_buffer_object *obj = inputs[i]->BufferObj;
+ assert(!_mesa_bufferobj_mapped(obj));
+ (void) obj;
+ }
+ }
+#endif
+}
+
+
+/**
+ * A debug function that may be called from other parts of Mesa as
+ * needed during debugging.
+ */
+void
+vbo_check_buffers_are_unmapped(struct gl_context *ctx)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct vbo_exec_context *exec = &vbo->exec;
+ /* check the current vertex arrays */
+ check_buffers_are_unmapped(exec->array.inputs);
+ /* check the current glBegin/glVertex/glEnd-style VBO */
+ assert(!_mesa_bufferobj_mapped(exec->vtx.bufferobj));
+}
+
+
+
+/**
* Compute min and max elements by scanning the index buffer for
* glDraw[Range]Elements() calls.
* If primitive restart is enabled, we need to ignore restart
@@ -423,6 +461,14 @@ recalculate_input_bindings(struct gl_context *ctx)
inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
}
+
+ /* There is no need to make _NEW_ARRAY dirty here for the TnL program,
+ * because it already takes care of invalidating the state necessary
+ * to revalidate vertex arrays. Not marking the state as dirty also
+ * improves performance (quite significantly in some apps).
+ */
+ if (!ctx->VertexProgram._MaintainTnlProgram)
+ ctx->NewState |= _NEW_ARRAY;
break;
case VP_NV:
@@ -448,6 +494,8 @@ recalculate_input_bindings(struct gl_context *ctx)
inputs[i] = &vbo->generic_currval[i - VERT_ATTRIB_GENERIC0];
const_inputs |= 1 << i;
}
+
+ ctx->NewState |= _NEW_ARRAY;
break;
case VP_ARB:
@@ -483,8 +531,9 @@ recalculate_input_bindings(struct gl_context *ctx)
inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
const_inputs |= 1 << (VERT_ATTRIB_GENERIC0 + i);
}
-
}
+
+ ctx->NewState |= _NEW_ARRAY;
break;
}
@@ -502,8 +551,13 @@ recalculate_input_bindings(struct gl_context *ctx)
static void
bind_arrays(struct gl_context *ctx)
{
+ if (!ctx->Array.RebindArrays) {
+ return;
+ }
+
bind_array_obj(ctx);
recalculate_input_bindings(ctx);
+ ctx->Array.RebindArrays = GL_FALSE;
}
@@ -576,6 +630,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
if (primCount > 0) {
/* draw one or two prims */
+ check_buffers_are_unmapped(exec->array.inputs);
vbo->draw_prims(ctx, exec->array.inputs, prim, primCount, NULL,
GL_TRUE, start, start + count - 1);
}
@@ -585,6 +640,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
prim[0].start = start;
prim[0].count = count;
+ check_buffers_are_unmapped(exec->array.inputs);
vbo->draw_prims(ctx, exec->array.inputs, prim, 1, NULL,
GL_TRUE, start, start + count - 1);
}
@@ -629,15 +685,15 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
*/
static void GLAPIENTRY
vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
- GLsizei primcount)
+ GLsizei numInstances)
{
GET_CURRENT_CONTEXT(ctx);
if (MESA_VERBOSE & VERBOSE_DRAW)
_mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n",
- _mesa_lookup_enum_by_nr(mode), start, count, primcount);
+ _mesa_lookup_enum_by_nr(mode), start, count, numInstances);
- if (!_mesa_validate_DrawArraysInstanced(ctx, mode, start, count, primcount))
+ if (!_mesa_validate_DrawArraysInstanced(ctx, mode, start, count, numInstances))
return;
FLUSH_CURRENT( ctx, 0 );
@@ -649,7 +705,7 @@ vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
if (0)
check_draw_arrays_data(ctx, start, count);
- vbo_draw_arrays(ctx, mode, start, count, primcount);
+ vbo_draw_arrays(ctx, mode, start, count, numInstances);
if (0)
print_draw_arrays(ctx, mode, start, count);
@@ -724,7 +780,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
GLuint start, GLuint end,
GLsizei count, GLenum type,
const GLvoid *indices,
- GLint basevertex, GLint primcount)
+ GLint basevertex, GLint numInstances)
{
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
@@ -757,7 +813,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
prim[0].count = count;
prim[0].indexed = 1;
prim[0].basevertex = basevertex;
- prim[0].num_instances = primcount;
+ prim[0].num_instances = numInstances;
/* Need to give special consideration to rendering a range of
* indices starting somewhere above zero. Typically the
@@ -790,6 +846,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
* for the latter case elsewhere.
*/
+ check_buffers_are_unmapped(exec->array.inputs);
vbo->draw_prims( ctx, exec->array.inputs, prim, 1, &ib,
index_bounds_valid, start, end );
}
@@ -977,21 +1034,21 @@ vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
*/
static void GLAPIENTRY
vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices, GLsizei primcount)
+ const GLvoid *indices, GLsizei numInstances)
{
GET_CURRENT_CONTEXT(ctx);
if (MESA_VERBOSE & VERBOSE_DRAW)
_mesa_debug(ctx, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n",
_mesa_lookup_enum_by_nr(mode), count,
- _mesa_lookup_enum_by_nr(type), indices, primcount);
+ _mesa_lookup_enum_by_nr(type), indices, numInstances);
if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
- primcount))
+ numInstances))
return;
vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
- count, type, indices, 0, primcount);
+ count, type, indices, 0, numInstances);
}
@@ -1106,6 +1163,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
prim[i].basevertex = 0;
}
+ check_buffers_are_unmapped(exec->array.inputs);
vbo->draw_prims(ctx, exec->array.inputs, prim, primcount, &ib,
GL_FALSE, ~0, ~0);
} else {
@@ -1130,6 +1188,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
else
prim[0].basevertex = 0;
+ check_buffers_are_unmapped(exec->array.inputs);
vbo->draw_prims(ctx, exec->array.inputs, prim, 1, &ib,
GL_FALSE, ~0, ~0);
}
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 94aa021ac9..539658021e 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -29,6 +29,7 @@
#include "main/bufferobj.h"
#include "main/compiler.h"
#include "main/enums.h"
+#include "main/mfeatures.h"
#include "main/state.h"
#include "vbo_context.h"
@@ -244,6 +245,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
arrays[attr]._MaxElement = count; /* ??? */
varying_inputs |= 1 << attr;
+ ctx->NewState |= _NEW_ARRAY;
}
}
@@ -251,6 +253,9 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
}
+/**
+ * Unmap the VBO. This is called before drawing.
+ */
static void
vbo_exec_vtx_unmap( struct vbo_exec_context *exec )
{
@@ -283,6 +288,9 @@ vbo_exec_vtx_unmap( struct vbo_exec_context *exec )
}
+/**
+ * Map the vertex buffer to begin storing glVertex, glColor, etc data.
+ */
void
vbo_exec_vtx_map( struct vbo_exec_context *exec )
{
@@ -299,14 +307,12 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec )
if (!_mesa_is_bufferobj(exec->vtx.bufferobj))
return;
- if (exec->vtx.buffer_map != NULL) {
- assert(0);
- exec->vtx.buffer_map = NULL;
- exec->vtx.buffer_ptr = NULL;
- }
+ assert(!exec->vtx.buffer_map);
+ assert(!exec->vtx.buffer_ptr);
if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 &&
ctx->Driver.MapBufferRange) {
+ /* The VBO exists and there's room for more */
exec->vtx.buffer_map =
(GLfloat *)ctx->Driver.MapBufferRange(ctx,
target,
@@ -319,6 +325,7 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec )
}
if (!exec->vtx.buffer_map) {
+ /* Need to allocate a new VBO */
exec->vtx.buffer_used = 0;
ctx->Driver.BufferData(ctx, target,
@@ -347,9 +354,10 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec )
/**
* 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 unmap )
+vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped)
{
if (0)
vbo_exec_debug_verts( exec );
@@ -389,7 +397,7 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap )
/* If using a real VBO, get new storage -- unless asked not to.
*/
- if (_mesa_is_bufferobj(exec->vtx.bufferobj) && !unmap) {
+ if (_mesa_is_bufferobj(exec->vtx.bufferobj) && !keepUnmapped) {
vbo_exec_vtx_map( exec );
}
}
@@ -397,14 +405,13 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap )
/* May have to unmap explicitly if we didn't draw:
*/
- if (unmap &&
+ if (keepUnmapped &&
_mesa_is_bufferobj(exec->vtx.bufferobj) &&
exec->vtx.buffer_map) {
vbo_exec_vtx_unmap( exec );
}
-
- if (unmap || exec->vtx.vertex_size == 0)
+ 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) /
diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c
index 4e7bcddc97..4343b34818 100644
--- a/src/mesa/vbo/vbo_save.c
+++ b/src/mesa/vbo/vbo_save.c
@@ -29,6 +29,7 @@
#include "main/mtypes.h"
#include "main/bufferobj.h"
#include "main/imports.h"
+#include "main/mfeatures.h"
#include "vbo_context.h"
diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index f5a407ced1..cd827ce6c0 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -34,6 +34,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef VBO_SAVE_H
#define VBO_SAVE_H
+#include "main/mfeatures.h"
#include "main/mtypes.h"
#include "vbo.h"
#include "vbo_attrib.h"
@@ -96,7 +97,9 @@ struct vbo_save_vertex_list {
*/
#define VBO_SAVE_BUFFER_SIZE (8*1024) /* dwords */
#define VBO_SAVE_PRIM_SIZE 128
-#define VBO_SAVE_PRIM_WEAK 0x40
+#define VBO_SAVE_PRIM_MODE_MASK 0x3f
+#define VBO_SAVE_PRIM_WEAK 0x40
+#define VBO_SAVE_PRIM_NO_CURRENT_UPDATE 0x80
#define VBO_SAVE_FALLBACK 0x10000000
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 817d478e2a..836c76fe83 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -74,6 +74,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "main/enums.h"
#include "main/eval.h"
#include "main/macros.h"
+#include "main/mfeatures.h"
#include "main/api_noop.h"
#include "main/api_validate.h"
#include "main/api_arrayelt.h"
@@ -294,26 +295,30 @@ static void _save_compile_vertex_list( struct gl_context *ctx )
node->vertex_store->refcount++;
node->prim_store->refcount++;
-
- node->current_size = node->vertex_size - node->attrsz[0];
- node->current_data = NULL;
-
- if (node->current_size) {
- /* If the malloc fails, we just pull the data out of the VBO
- * later instead.
- */
- node->current_data = MALLOC( node->current_size * sizeof(GLfloat) );
- if (node->current_data) {
- const char *buffer = (const char *)save->vertex_store->buffer;
- unsigned attr_offset = node->attrsz[0] * sizeof(GLfloat);
- unsigned vertex_offset = 0;
-
- if (node->count)
- vertex_offset = (node->count-1) * node->vertex_size * sizeof(GLfloat);
-
- memcpy( node->current_data,
- buffer + node->buffer_offset + vertex_offset + attr_offset,
- node->current_size * sizeof(GLfloat) );
+ if (node->prim[0].no_current_update) {
+ node->current_size = 0;
+ node->current_data = NULL;
+ } else {
+ node->current_size = node->vertex_size - node->attrsz[0];
+ node->current_data = NULL;
+
+ if (node->current_size) {
+ /* If the malloc fails, we just pull the data out of the VBO
+ * later instead.
+ */
+ node->current_data = MALLOC( node->current_size * sizeof(GLfloat) );
+ if (node->current_data) {
+ const char *buffer = (const char *)save->vertex_store->buffer;
+ unsigned attr_offset = node->attrsz[0] * sizeof(GLfloat);
+ unsigned vertex_offset = 0;
+
+ if (node->count)
+ vertex_offset = (node->count-1) * node->vertex_size * sizeof(GLfloat);
+
+ memcpy( node->current_data,
+ buffer + node->buffer_offset + vertex_offset + attr_offset,
+ node->current_size * sizeof(GLfloat) );
+ }
}
}
@@ -397,6 +402,7 @@ static void _save_wrap_buffers( struct gl_context *ctx )
GLint i = save->prim_count - 1;
GLenum mode;
GLboolean weak;
+ GLboolean no_current_update;
assert(i < (GLint) save->prim_max);
assert(i >= 0);
@@ -407,6 +413,7 @@ static void _save_wrap_buffers( struct gl_context *ctx )
save->prim[i].start);
mode = save->prim[i].mode;
weak = save->prim[i].weak;
+ no_current_update = save->prim[i].no_current_update;
/* store the copied vertices, and allocate a new list.
*/
@@ -416,6 +423,7 @@ static void _save_wrap_buffers( struct gl_context *ctx )
*/
save->prim[0].mode = mode;
save->prim[0].weak = weak;
+ save->prim[0].no_current_update = no_current_update;
save->prim[0].begin = 0;
save->prim[0].end = 0;
save->prim[0].pad = 0;
@@ -625,7 +633,7 @@ static void _save_reset_vertex( struct gl_context *ctx )
-#define ERROR() _mesa_compile_error( ctx, GL_INVALID_ENUM, __FUNCTION__ );
+#define ERROR(err) _mesa_compile_error( ctx, err, __FUNCTION__ );
/* Only one size for each attribute may be active at once. Eg. if
@@ -638,11 +646,11 @@ static void _save_reset_vertex( struct gl_context *ctx )
do { \
struct vbo_save_context *save = &vbo_context(ctx)->save; \
\
- if (save->active_sz[A] != N) \
+ if (save->active_sz[A] != N) \
save_fixup_vertex(ctx, A, N); \
\
{ \
- GLfloat *dest = save->attrptr[A]; \
+ GLfloat *dest = save->attrptr[A]; \
if (N>0) dest[0] = V0; \
if (N>1) dest[1] = V1; \
if (N>2) dest[2] = V2; \
@@ -655,7 +663,7 @@ do { \
for (i = 0; i < save->vertex_size; i++) \
save->buffer_ptr[i] = save->vertex[i]; \
\
- save->buffer_ptr += save->vertex_size; \
+ save->buffer_ptr += save->vertex_size; \
\
if (++save->vert_count >= save->max_vert) \
_save_wrap_filled_vertex( ctx ); \
@@ -770,10 +778,11 @@ GLboolean vbo_save_NotifyBegin( struct gl_context *ctx, GLenum mode )
GLuint i = save->prim_count++;
assert(i < save->prim_max);
- save->prim[i].mode = mode & ~VBO_SAVE_PRIM_WEAK;
+ save->prim[i].mode = mode & VBO_SAVE_PRIM_MODE_MASK;
save->prim[i].begin = 1;
save->prim[i].end = 0;
save->prim[i].weak = (mode & VBO_SAVE_PRIM_WEAK) ? 1 : 0;
+ save->prim[i].no_current_update = (mode & VBO_SAVE_PRIM_NO_CURRENT_UPDATE) ? 1 : 0;
save->prim[i].pad = 0;
save->prim[i].start = save->vert_count;
save->prim[i].count = 0;
@@ -934,7 +943,7 @@ static void GLAPIENTRY _save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei co
_ae_map_vbos( ctx );
- vbo_save_NotifyBegin( ctx, mode | VBO_SAVE_PRIM_WEAK );
+ vbo_save_NotifyBegin( ctx, mode | VBO_SAVE_PRIM_WEAK | VBO_SAVE_PRIM_NO_CURRENT_UPDATE);
for (i = 0; i < count; i++)
CALL_ArrayElement(GET_DISPATCH(), (start + i));
@@ -960,7 +969,7 @@ static void GLAPIENTRY _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum
if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj))
indices = ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Pointer, indices);
- vbo_save_NotifyBegin( ctx, mode | VBO_SAVE_PRIM_WEAK );
+ vbo_save_NotifyBegin( ctx, mode | VBO_SAVE_PRIM_WEAK | VBO_SAVE_PRIM_NO_CURRENT_UPDATE );
switch (type) {
case GL_UNSIGNED_BYTE:
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 533c150a91..634a6d3f84 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -30,6 +30,7 @@
#include "main/bufferobj.h"
#include "main/context.h"
#include "main/imports.h"
+#include "main/mfeatures.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "main/light.h"
@@ -201,6 +202,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
buffer_offset += node->attrsz[src] * sizeof(GLfloat);
varying_inputs |= 1<<attr;
+ ctx->NewState |= _NEW_ARRAY;
}
}
diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c
index b1cfa9c2a8..51e598e7e6 100644
--- a/src/mesa/vbo/vbo_save_loopback.c
+++ b/src/mesa/vbo/vbo_save_loopback.c
@@ -29,6 +29,7 @@
#include "main/glheader.h"
#include "main/enums.h"
#include "main/imports.h"
+#include "main/mfeatures.h"
#include "main/mtypes.h"
#include "main/dispatch.h"
#include "glapi/glapi.h"
diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c
index 26d0046e83..8c981f93e5 100644
--- a/src/mesa/vbo/vbo_split_copy.c
+++ b/src/mesa/vbo/vbo_split_copy.c
@@ -222,6 +222,7 @@ begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag )
prim->mode = mode;
prim->begin = begin_flag;
+ prim->num_instances = 1;
}
diff --git a/src/mesa/vbo/vbo_split_inplace.c b/src/mesa/vbo/vbo_split_inplace.c
index 789cf31364..f6aa576b6c 100644
--- a/src/mesa/vbo/vbo_split_inplace.c
+++ b/src/mesa/vbo/vbo_split_inplace.c
@@ -178,6 +178,7 @@ static void split_prims( struct split_context *split)
outprim->end = (nr == remaining && prim->end);
outprim->start = prim->start + j;
outprim->count = nr;
+ outprim->num_instances = prim->num_instances;
update_index_bounds(split, outprim);
@@ -221,6 +222,7 @@ static void split_prims( struct split_context *split)
tmpprim.indexed = 1;
tmpprim.start = 0;
tmpprim.count = count;
+ tmpprim.num_instances = 1;
flush_vertex(split);