From: Marek Olšák <marek.ol...@amd.com>

---
 src/gallium/auxiliary/pipebuffer/pb_cache.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/pipebuffer/pb_cache.c 
b/src/gallium/auxiliary/pipebuffer/pb_cache.c
index b67e54b..dd479ae 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_cache.c
@@ -47,34 +47,32 @@ destroy_buffer_locked(struct pb_cache_entry *entry)
       --mgr->num_buffers;
       mgr->cache_size -= buf->size;
    }
    mgr->destroy_buffer(buf);
 }
 
 /**
  * Free as many cache buffers from the list head as possible.
  */
 static void
-release_expired_buffers_locked(struct list_head *cache)
+release_expired_buffers_locked(struct list_head *cache,
+                               int64_t current_time)
 {
    struct list_head *curr, *next;
    struct pb_cache_entry *entry;
-   int64_t now;
-
-   now = os_time_get();
 
    curr = cache->next;
    next = curr->next;
    while (curr != cache) {
       entry = LIST_ENTRY(struct pb_cache_entry, curr, head);
 
-      if (!os_time_timeout(entry->start, entry->end, now))
+      if (!os_time_timeout(entry->start, entry->end, current_time))
          break;
 
       destroy_buffer_locked(entry);
 
       curr = next;
       next = curr->next;
    }
 }
 
 /**
@@ -85,22 +83,24 @@ void
 pb_cache_add_buffer(struct pb_cache_entry *entry)
 {
    struct pb_cache *mgr = entry->mgr;
    struct list_head *cache = &mgr->buckets[entry->bucket_index];
    struct pb_buffer *buf = entry->buffer;
    unsigned i;
 
    mtx_lock(&mgr->mutex);
    assert(!pipe_is_referenced(&buf->reference));
 
+   int64_t current_time = os_time_get();
+
    for (i = 0; i < ARRAY_SIZE(mgr->buckets); i++)
-      release_expired_buffers_locked(&mgr->buckets[i]);
+      release_expired_buffers_locked(&mgr->buckets[i], current_time);
 
    /* Directly release any buffer that exceeds the limit. */
    if (mgr->cache_size + buf->size > mgr->max_cache_size) {
       mgr->destroy_buffer(buf);
       mtx_unlock(&mgr->mutex);
       return;
    }
 
    entry->start = os_time_get();
    entry->end = entry->start + mgr->usecs;
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to