mesa: Use atomics for buffer objects reference counts.
authorMathias Fröhlich <mathias.froehlich@web.de>
Sat, 3 Feb 2018 14:06:16 +0000 (15:06 +0100)
committerMathias Fröhlich <Mathias.Froehlich@gmx.net>
Tue, 6 Feb 2018 20:20:14 +0000 (21:20 +0100)
commit2313c33e950a1b17e7787dd8a3b2f1e823d0cfd4
treea885ab8dd272795da341bfd1747cb36d9de90a84
parent6c691081a183aec51d5305592b9fa391ebb447ab
mesa: Use atomics for buffer objects reference counts.

The mutex is currently used for reference counting and updating
the minmax index cache.
The change uses atomics directly for reference counting and
the mutex for the minmax cache.
This is safe since the reference count is not modified beside
in _mesa_reference_buffer_object where atomics aim to be used.
While using the minmax cache, the calling code holds a reference
to the buffer object. Thus unreferencing or even referencing the
buffer object does not need to be serialized with accessing
the minmax cache.
The change reduces the time _mesa_reference_buffer_object_ takes
by about a factor of two when looking at perf results for some
of my favorite use cases.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/main/bufferobj.c
src/mesa/main/mtypes.h
src/mesa/vbo/vbo_minmax_index.c