mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 08:10:09 +01:00
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@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
This commit is contained in:
parent
cf82b3dc74
commit
104a41bd07
1 changed files with 8 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue