Mesa (master): mesa: avoid redundant VBO updates
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 23 05:09:01 UTC 2020
Module: Mesa
Branch: master
Commit: 7e1b57a6d964ac58e84ec4ece2951e4e643d6b1a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e1b57a6d964ac58e84ec4ece2951e4e643d6b1a
Author: Rob Clark <robdclark at chromium.org>
Date: Thu Apr 16 09:46:04 2020 -0700
mesa: avoid redundant VBO updates
Avoids re-emitting unchanged VBO state, which is a big chunk of the
state updates in gfxbench driver2
Signed-off-by: Rob Clark <robdclark at chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4619>
---
src/mesa/main/varray.c | 23 ++++++++++++++---------
src/mesa/vbo/vbo_private.h | 7 +------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 559ff9d949f..71ba518f2d1 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -627,14 +627,21 @@ _mesa_update_array_format(struct gl_context *ctx,
GLuint relativeOffset)
{
struct gl_array_attributes *const array = &vao->VertexAttrib[attrib];
+ struct gl_vertex_format new_format;
assert(!vao->SharedAndImmutable);
assert(size <= 4);
- array->RelativeOffset = relativeOffset;
- _mesa_set_vertex_format(&array->Format, size, type, format,
+ _mesa_set_vertex_format(&new_format, size, type, format,
normalized, integer, doubles);
+ if ((array->RelativeOffset == relativeOffset) &&
+ !memcmp(&new_format, &array->Format, sizeof(new_format)))
+ return;
+
+ array->RelativeOffset = relativeOffset;
+ array->Format = new_format;
+
vao->NewArrays |= vao->Enabled & VERT_BIT(attrib);
}
@@ -891,13 +898,11 @@ update_array(struct gl_context *ctx,
/* The Stride and Ptr fields are not set by update_array_format() */
struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
- array->Stride = stride;
- /* For updating the pointer we would need to add the vao->NewArrays flag
- * to the VAO. But but that is done already unconditionally in
- * _mesa_update_array_format called above.
- */
- assert((vao->NewArrays | ~vao->Enabled) & VERT_BIT(attrib));
- array->Ptr = ptr;
+ if ((array->Stride != stride) || (array->Ptr != ptr)) {
+ array->Stride = stride;
+ array->Ptr = ptr;
+ vao->NewArrays |= vao->Enabled & VERT_BIT(attrib);
+ }
/* Update the vertex buffer binding */
GLsizei effectiveStride = stride != 0 ?
diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index a70ba0a032c..85396654682 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -243,12 +243,7 @@ _vbo_set_attrib_format(struct gl_context *ctx,
size /= 2;
_mesa_update_array_format(ctx, vao, attr, size, type, GL_RGBA,
GL_FALSE, integer, doubles, offset);
- /* Ptr for userspace arrays.
- * For updating the pointer we would need to add the vao->NewArrays flag
- * to the VAO. But but that is done already unconditionally in
- * _mesa_update_array_format called above.
- */
- assert((vao->NewArrays | ~vao->Enabled) & VERT_BIT(attr));
+ vao->NewArrays |= vao->Enabled & VERT_BIT(attr);
vao->VertexAttrib[attr].Ptr = ADD_POINTERS(buffer_offset, offset);
}
More information about the mesa-commit
mailing list