aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/vbo/vbo_save_api.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-02-13 09:10:55 +0100
committermarha <marha@users.sourceforge.net>2013-02-13 09:10:55 +0100
commit8add148a4cf71b8bdab05a6b7e14824b5062da5e (patch)
tree8e1c46d5e3884612833ae099806391c5db4d3792 /mesalib/src/mesa/vbo/vbo_save_api.c
parent8753441b3ba4316448e1ae5f408e6a84b0116a3c (diff)
downloadvcxsrv-8add148a4cf71b8bdab05a6b7e14824b5062da5e.tar.gz
vcxsrv-8add148a4cf71b8bdab05a6b7e14824b5062da5e.tar.bz2
vcxsrv-8add148a4cf71b8bdab05a6b7e14824b5062da5e.zip
mesa pixman xserver git update 13 Feb 2013
xserver commit 7115f6c709898a5124b67e19c61dc01334471358 pixman commit 5e207f825bd1ed3142a623bcbceca00508907c5e mesa commit 8cabe26f5dc4c66ae59649cfd7b25f761cda250b
Diffstat (limited to 'mesalib/src/mesa/vbo/vbo_save_api.c')
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c59
1 files changed, 51 insertions, 8 deletions
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index b4c90a05c..749071753 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -301,6 +301,47 @@ _save_reset_counters(struct gl_context *ctx)
save->dangling_attr_ref = 0;
}
+/**
+ * For a list of prims, try merging prims that can just be extensions of the
+ * previous prim.
+ */
+static void
+vbo_merge_prims(struct gl_context *ctx,
+ struct _mesa_prim *prim_list,
+ GLuint *prim_count)
+{
+ GLuint i;
+ struct _mesa_prim *prev_prim = prim_list;
+
+ for (i = 1; i < *prim_count; i++) {
+ struct _mesa_prim *this_prim = prim_list + i;
+
+ if (this_prim->mode == prev_prim->mode &&
+ this_prim->mode == GL_QUADS &&
+ this_prim->count % 4 == 0 &&
+ prev_prim->count % 4 == 0 &&
+ this_prim->start == prev_prim->start + prev_prim->count &&
+ this_prim->basevertex == prev_prim->basevertex &&
+ this_prim->num_instances == prev_prim->num_instances &&
+ this_prim->base_instance == prev_prim->base_instance) {
+ /* We've found a prim that just extend the previous one. Tack it
+ * onto the previous one, and let this primitive struct get dropped.
+ */
+ prev_prim->count += this_prim->count;
+ prev_prim->end = this_prim->end;
+ continue;
+ }
+
+ /* If any previous primitives have been dropped, then we need to copy
+ * this later one into the next available slot.
+ */
+ prev_prim++;
+ if (prev_prim != this_prim)
+ *prev_prim = *this_prim;
+ }
+
+ *prim_count = prev_prim - prim_list + 1;
+}
/**
* Insert the active immediate struct onto the display list currently
@@ -380,6 +421,8 @@ _save_compile_vertex_list(struct gl_context *ctx)
*/
save->copied.nr = _save_copy_vertices(ctx, node, save->buffer);
+ vbo_merge_prims(ctx, node->prim, &node->prim_count);
+
/* Deal with GL_COMPILE_AND_EXECUTE:
*/
if (ctx->ExecuteFlag) {
@@ -1595,14 +1638,14 @@ vbo_print_vertex_list(struct gl_context *ctx, void *data)
for (i = 0; i < node->prim_count; i++) {
struct _mesa_prim *prim = &node->prim[i];
- _mesa_debug(NULL, " prim %d: %s%s %d..%d %s %s\n",
- i,
- _mesa_lookup_prim_by_nr(prim->mode),
- prim->weak ? " (weak)" : "",
- prim->start,
- prim->start + prim->count,
- (prim->begin) ? "BEGIN" : "(wrap)",
- (prim->end) ? "END" : "(wrap)");
+ printf(" prim %d: %s%s %d..%d %s %s\n",
+ i,
+ _mesa_lookup_prim_by_nr(prim->mode),
+ prim->weak ? " (weak)" : "",
+ prim->start,
+ prim->start + prim->count,
+ (prim->begin) ? "BEGIN" : "(wrap)",
+ (prim->end) ? "END" : "(wrap)");
}
}