diff options
author | Mathias Fröhlich <[email protected]> | 2018-02-03 15:06:16 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-02-06 21:20:14 +0100 |
commit | 2313c33e950a1b17e7787dd8a3b2f1e823d0cfd4 (patch) | |
tree | a885ab8dd272795da341bfd1747cb36d9de90a84 /src/mesa/vbo | |
parent | 6c691081a183aec51d5305592b9fa391ebb447ab (diff) |
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 <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r-- | src/mesa/vbo/vbo_minmax_index.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mesa/vbo/vbo_minmax_index.c b/src/mesa/vbo/vbo_minmax_index.c index c9d20201672..d1298dcdc3a 100644 --- a/src/mesa/vbo/vbo_minmax_index.c +++ b/src/mesa/vbo/vbo_minmax_index.c @@ -115,7 +115,7 @@ vbo_get_minmax_cached(struct gl_buffer_object *bufferObj, if (!vbo_use_minmax_cache(bufferObj)) return GL_FALSE; - simple_mtx_lock(&bufferObj->Mutex); + simple_mtx_lock(&bufferObj->MinMaxCacheMutex); if (bufferObj->MinMaxCacheDirty) { /* Disable the cache permanently for this BO if the number of hits @@ -166,7 +166,7 @@ out_invalidate: } out_disable: - simple_mtx_unlock(&bufferObj->Mutex); + simple_mtx_unlock(&bufferObj->MinMaxCacheMutex); return found; } @@ -184,7 +184,7 @@ vbo_minmax_cache_store(struct gl_context *ctx, if (!vbo_use_minmax_cache(bufferObj)) return; - simple_mtx_lock(&bufferObj->Mutex); + simple_mtx_lock(&bufferObj->MinMaxCacheMutex); if (!bufferObj->MinMaxCache) { bufferObj->MinMaxCache = @@ -223,7 +223,7 @@ vbo_minmax_cache_store(struct gl_context *ctx, free(entry); out: - simple_mtx_unlock(&bufferObj->Mutex); + simple_mtx_unlock(&bufferObj->MinMaxCacheMutex); } |