Mesa (master): gallium/util: optimize pipe_vertex_buffer_reference binding the same buffer
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 00:13:26 UTC 2021
Module: Mesa
Branch: master
Commit: 104a41bd0743596f7eccadcef3a70a3d40c370d7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=104a41bd0743596f7eccadcef3a70a3d40c370d7
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sat Jan 2 16:35:15 2021 -0500
gallium/util: optimize pipe_vertex_buffer_reference binding the same buffer
This eliminates atomic ops when the buffer doesn't change.
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
---
src/gallium/auxiliary/util/u_inlines.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index d751f1cce28..f3a74d7fb0a 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -223,6 +223,14 @@ static inline void
pipe_vertex_buffer_reference(struct pipe_vertex_buffer *dst,
const struct pipe_vertex_buffer *src)
{
+ if (dst->buffer.resource == src->buffer.resource) {
+ /* Just copy the fields, don't touch reference counts. */
+ dst->stride = src->stride;
+ dst->is_user_buffer = src->is_user_buffer;
+ dst->buffer_offset = src->buffer_offset;
+ return;
+ }
+
pipe_vertex_buffer_unreference(dst);
if (!src->is_user_buffer)
pipe_resource_reference(&dst->buffer.resource, src->buffer.resource);
More information about the mesa-commit
mailing list