[gnome-remote-desktop] rdp-buffer-pool: Prefer buffers without mapped resources
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] rdp-buffer-pool: Prefer buffers without mapped resources
- Date: Thu, 3 Mar 2022 14:23:09 +0000 (UTC)
commit 2f07752754f3eeb7d236d0af16e142cab6dcd31a
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Sun Jan 9 23:30:45 2022 +0100
rdp-buffer-pool: Prefer buffers without mapped resources
When taking a buffer out of the buffer pool, the GL resources might
still be mapped from its last use.
While unmapping the pixel buffer object is a matter of tens of
microseconds, it still adds a delay.
Furthermore, when no frames are retrieved in gnome-remote-desktop, due
to the system being idle, the GPU driver downclocks the GPU.
The result is that the first two unmapping operations take several
milliseconds to complete, when gnome-remote-desktop receives some
frames again.
This, however, does not apply to the upload operation for some reason.
In addition to that, the mapping operations seem to perform faster for
some reason.
It might be the case, that the GPU driver already starts upclocking the
GPU, when data is uploaded to the GPU.
With this in mind, always prefer buffers, that don't need an unmap
operation.
In the next commits, the buffer pool receives a low priority GSource,
which unmaps all untaken buffers, when the main thread idles.
src/grd-rdp-buffer-pool.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/grd-rdp-buffer-pool.c b/src/grd-rdp-buffer-pool.c
index 42597d82..05bed058 100644
--- a/src/grd-rdp-buffer-pool.c
+++ b/src/grd-rdp-buffer-pool.c
@@ -115,6 +115,15 @@ grd_rdp_buffer_pool_resize_buffers (GrdRdpBufferPool *buffer_pool,
return TRUE;
}
+static gboolean
+buffer_has_mapped_data (GrdRdpBuffer *buffer)
+{
+ if (buffer->mapped_cuda_pointer)
+ return TRUE;
+
+ return FALSE;
+}
+
GrdRdpBuffer *
grd_rdp_buffer_pool_acquire (GrdRdpBufferPool *buffer_pool)
{
@@ -122,6 +131,7 @@ grd_rdp_buffer_pool_acquire (GrdRdpBufferPool *buffer_pool)
GHashTableIter iter;
GrdRdpBuffer *buffer;
BufferInfo *buffer_info;
+ gboolean buffer_found = FALSE;
locker = g_mutex_locker_new (&buffer_pool->pool_mutex);
if (g_hash_table_size (buffer_pool->buffer_table) <= buffer_pool->buffers_taken &&
@@ -132,9 +142,24 @@ grd_rdp_buffer_pool_acquire (GrdRdpBufferPool *buffer_pool)
while (g_hash_table_iter_next (&iter, (gpointer *) &buffer,
(gpointer *) &buffer_info))
{
- if (!buffer_info->buffer_taken)
- break;
+ if (!buffer_info->buffer_taken && !buffer_has_mapped_data (buffer))
+ {
+ buffer_found = TRUE;
+ break;
+ }
+ }
+
+ if (!buffer_found)
+ {
+ g_hash_table_iter_init (&iter, buffer_pool->buffer_table);
+ while (g_hash_table_iter_next (&iter, (gpointer *) &buffer,
+ (gpointer *) &buffer_info))
+ {
+ if (!buffer_info->buffer_taken)
+ break;
+ }
}
+ g_assert (buffer);
buffer_info->buffer_taken = TRUE;
++buffer_pool->buffers_taken;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]