[gnome-remote-desktop] rdp-buffer: Add API to unmap resources
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] rdp-buffer: Add API to unmap resources
- Date: Thu, 3 Mar 2022 14:23:09 +0000 (UTC)
commit 7b2affa4d53848bb9c1883bc7d890b061c39a441
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Tue Jan 11 16:43:22 2022 +0100
rdp-buffer: Add API to unmap resources
This API will be used in the next commit by the buffer pool to unmap
the GL resources of the buffer.
To unmap the GL resources, use the custom task API of the EGL thread to
queue an unmap.
Since all tasks in the EGL thread run in a queue, no synchronization is
required here.
src/grd-rdp-buffer.c | 43 +++++++++++++++++++++++++++++++++++++++++++
src/grd-rdp-buffer.h | 2 ++
2 files changed, 45 insertions(+)
---
diff --git a/src/grd-rdp-buffer.c b/src/grd-rdp-buffer.c
index 5cc2183f..242a725c 100644
--- a/src/grd-rdp-buffer.c
+++ b/src/grd-rdp-buffer.c
@@ -42,6 +42,13 @@ typedef struct
GrdRdpBuffer *buffer;
} AllocateBufferData;
+typedef struct
+{
+ GrdHwAccelNvidia *hwaccel_nvidia;
+ CUgraphicsResource cuda_resource;
+ CUstream cuda_stream;
+} UnmapBufferData;
+
GrdRdpBuffer *
grd_rdp_buffer_new (GrdRdpBufferPool *buffer_pool,
GrdEglThread *egl_thread,
@@ -110,6 +117,42 @@ grd_rdp_buffer_free (GrdRdpBuffer *buffer)
g_free (buffer);
}
+static gboolean
+cuda_unmap_resource (gpointer user_data)
+{
+ UnmapBufferData *data = user_data;
+
+ grd_hwaccel_nvidia_unmap_cuda_resource (data->hwaccel_nvidia,
+ data->cuda_resource,
+ data->cuda_stream);
+
+ return TRUE;
+}
+
+void
+grd_rdp_buffer_unmap_resources (GrdRdpBuffer *buffer)
+{
+ if (buffer->mapped_cuda_pointer)
+ {
+ UnmapBufferData *data;
+
+ data = g_new0 (UnmapBufferData, 1);
+ data->hwaccel_nvidia = buffer->hwaccel_nvidia;
+ data->cuda_resource = buffer->cuda_resource;
+ data->cuda_stream = buffer->cuda_stream;
+ grd_egl_thread_run_custom_task (buffer->egl_thread,
+ cuda_unmap_resource,
+ data,
+ NULL, data, g_free);
+
+ /*
+ * The mapped CUDA pointer indicates whether the resource is mapped, but
+ * it is itself not needed to unmap the resource.
+ */
+ buffer->mapped_cuda_pointer = 0;
+ }
+}
+
void
grd_rdp_buffer_release (GrdRdpBuffer *buffer)
{
diff --git a/src/grd-rdp-buffer.h b/src/grd-rdp-buffer.h
index 03c14503..54583094 100644
--- a/src/grd-rdp-buffer.h
+++ b/src/grd-rdp-buffer.h
@@ -52,6 +52,8 @@ GrdRdpBuffer *grd_rdp_buffer_new (GrdRdpBufferPool *buffer_pool,
void grd_rdp_buffer_free (GrdRdpBuffer *buffer);
+void grd_rdp_buffer_unmap_resources (GrdRdpBuffer *buffer);
+
void grd_rdp_buffer_release (GrdRdpBuffer *buffer);
gboolean grd_rdp_buffer_resize (GrdRdpBuffer *buffer,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]