[gnome-remote-desktop] build: Stop making the nv-codec-headers optional
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-remote-desktop] build: Stop making the nv-codec-headers optional
- Date: Thu, 3 Mar 2022 14:23:08 +0000 (UTC)
commit 557ab8ac9970fe978457292bc95a0a6e84e897b4
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Mon Jan 3 15:31:24 2022 +0100
build: Stop making the nv-codec-headers optional
The main reason to make the nv-codec-headers optional in GNOME 41 was
that Debian and Ubuntu did not have an updated version of it and it
wasn't clear, whether both will update their version.
As it turns out, Debian (and therefore Ubuntu too) did update their
packages and also enabled hardware acceleration using CUDA and NVENC in
gnome-remote-desktop 41.
Since these headers are MIT licensed and don't provide any patented
functionality, as they only load functions from the NVIDIA driver, if
it is available, they can be made obligatory.
This will also make reading the code of the framebuffer handling much
easier in the future, when implementing the mechanism to handle all
frame data on the GPU.
Therefore, remove the NVENC/CUDA option and make the nv-codec-headers
obligatory for the RDP backend.
config.h.meson | 3 ---
data/meson.build | 2 +-
meson.build | 18 +++---------------
meson_options.txt | 5 -----
src/grd-rdp-graphics-pipeline.c | 23 +----------------------
src/grd-rdp-graphics-pipeline.h | 2 --
src/grd-rdp-server.c | 22 ++--------------------
src/grd-session-rdp.c | 20 ++------------------
src/grd-session-rdp.h | 5 +----
src/meson.build | 16 ++++------------
10 files changed, 14 insertions(+), 102 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index fb558762..e9f9ea85 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -12,8 +12,5 @@
/* Defined if VNC backend is enabled */
#mesondefine HAVE_VNC
-/* Defined if CUDA is available */
-#mesondefine HAVE_HWACCEL_NVIDIA
-
/* Path of the data dir */
#mesondefine GRD_DATA_DIR
diff --git a/data/meson.build b/data/meson.build
index faa51473..ac276bf4 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,4 +1,4 @@
-if have_hwaccel_nvidia
+if have_rdp
install_data(['grd-cuda-avc-utils_30.ptx'],
install_dir: grd_datadir,
)
diff --git a/meson.build b/meson.build
index 8171c635..55343cf3 100644
--- a/meson.build
+++ b/meson.build
@@ -28,30 +28,23 @@ drm_dep = dependency('libdrm')
have_rdp = get_option('rdp')
have_vnc = get_option('vnc')
-have_hwaccel_nvidia = get_option('nvenc_and_cuda')
if not have_rdp and not have_vnc
error('Must enable at least one backend')
endif
-if have_hwaccel_nvidia and not have_rdp
- error('Support for hardware acceleration using NVENC requires the RDP backend')
-endif
-
if have_rdp
add_global_arguments('-D_GNU_SOURCE', language : 'c')
+ dl_dep = cc.find_library('dl', required: true)
+
+ cuda_dep = dependency('ffnvcodec', version: cuda_req)
freerdp_dep = dependency('freerdp2', version: freerdp_req)
freerdp_client_dep = dependency('freerdp-client2', version: freerdp_req)
freerdp_server_dep = dependency('freerdp-server2', version: freerdp_req)
fuse_dep = dependency('fuse3', version: fuse_req)
winpr_dep = dependency('winpr2', version: freerdp_req)
xkbcommon_dep = dependency('xkbcommon', version: xkbcommon_req)
-
- if have_hwaccel_nvidia
- dl_dep = cc.find_library('dl', required: true)
- cuda_dep = dependency('ffnvcodec', version: cuda_req)
- endif
endif
if have_vnc
@@ -72,7 +65,6 @@ cdata.set_quoted('VERSION', meson.project_version())
cdata.set('HAVE_RDP', have_rdp)
cdata.set('HAVE_VNC', have_vnc)
-cdata.set('HAVE_HWACCEL_NVIDIA', have_hwaccel_nvidia)
cdata.set_quoted('GRD_DATA_DIR', grd_datadir)
@@ -120,10 +112,6 @@ output = [
' RDP...................... ' + have_rdp.to_string(),
' VNC...................... ' + have_vnc.to_string(),
'',
- ' Options for the RDP backend:',
- '',
- ' Support for hardware acceleration using NVENC and CUDA........' + have_hwaccel_nvidia.to_string(),
- '',
' Now type \'ninja -C ' + meson.build_root() + '\' to build ' + meson.project_name(),
'',
'',
diff --git a/meson_options.txt b/meson_options.txt
index 16d46d1b..35275885 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,11 +8,6 @@ option('vnc',
value: true,
description: 'Enable the VNC backend')
-option('nvenc_and_cuda',
- type: 'boolean',
- value: true,
- description: 'Build with support for hardware acceleration using NVENC and CUDA')
-
option('systemd',
type: 'boolean',
value: true,
diff --git a/src/grd-rdp-graphics-pipeline.c b/src/grd-rdp-graphics-pipeline.c
index a5e4dda5..9cb02c84 100644
--- a/src/grd-rdp-graphics-pipeline.c
+++ b/src/grd-rdp-graphics-pipeline.c
@@ -23,6 +23,7 @@
#include <winpr/sysinfo.h>
+#include "grd-hwaccel-nvidia.h"
#include "grd-rdp-buffer.h"
#include "grd-rdp-frame-info.h"
#include "grd-rdp-gfx-surface.h"
@@ -30,10 +31,6 @@
#include "grd-rdp-surface.h"
#include "grd-session-rdp.h"
-#ifdef HAVE_HWACCEL_NVIDIA
-#include "grd-hwaccel-nvidia.h"
-#endif /* HAVE_HWACCEL_NVIDIA */
-
#define ENC_TIMES_CHECK_INTERVAL_MS 1000
#define MAX_TRACKED_ENC_FRAMES 1000
@@ -100,9 +97,7 @@ struct _GrdRdpGraphicsPipeline
GQueue *enc_times;
GHashTable *surface_hwaccel_table;
-#ifdef HAVE_HWACCEL_NVIDIA
GrdHwAccelNvidia *hwaccel_nvidia;
-#endif /* HAVE_HWACCEL_NVIDIA */
uint32_t next_frame_id;
uint16_t next_surface_id;
@@ -111,14 +106,12 @@ struct _GrdRdpGraphicsPipeline
G_DEFINE_TYPE (GrdRdpGraphicsPipeline, grd_rdp_graphics_pipeline, G_TYPE_OBJECT)
-#ifdef HAVE_HWACCEL_NVIDIA
void
grd_rdp_graphics_pipeline_set_hwaccel_nvidia (GrdRdpGraphicsPipeline *graphics_pipeline,
GrdHwAccelNvidia *hwaccel_nvidia)
{
graphics_pipeline->hwaccel_nvidia = hwaccel_nvidia;
}
-#endif /* HAVE_HWACCEL_NVIDIA */
void
grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipeline,
@@ -130,10 +123,8 @@ grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipel
uint16_t surface_id = grd_rdp_gfx_surface_get_surface_id (gfx_surface);
uint32_t surface_serial = grd_rdp_gfx_surface_get_serial (gfx_surface);
GfxSurfaceContext *surface_context;
-#ifdef HAVE_HWACCEL_NVIDIA
HWAccelContext *hwaccel_context;
uint32_t encode_session_id;
-#endif /* HAVE_HWACCEL_NVIDIA */
surface_context = g_malloc0 (sizeof (GfxSurfaceContext));
@@ -145,7 +136,6 @@ grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipel
g_hash_table_insert (graphics_pipeline->serial_surface_table,
GUINT_TO_POINTER (surface_serial), surface_context);
-#ifdef HAVE_HWACCEL_NVIDIA
if ((rdpgfx_context->rdpcontext->settings->GfxAVC444v2 ||
rdpgfx_context->rdpcontext->settings->GfxAVC444 ||
rdpgfx_context->rdpcontext->settings->GfxH264) &&
@@ -165,7 +155,6 @@ grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipel
g_hash_table_insert (graphics_pipeline->surface_hwaccel_table,
GUINT_TO_POINTER (surface_id), hwaccel_context);
}
-#endif /* HAVE_HWACCEL_NVIDIA */
g_mutex_unlock (&graphics_pipeline->gfx_mutex);
create_surface.surfaceId = surface_id;
@@ -185,9 +174,7 @@ grd_rdp_graphics_pipeline_delete_surface (GrdRdpGraphicsPipeline *graphics_pipel
RDPGFX_DELETE_SURFACE_PDU delete_surface = {0};
gboolean needs_encoding_context_deletion = FALSE;
GfxSurfaceContext *surface_context;
-#ifdef HAVE_HWACCEL_NVIDIA
HWAccelContext *hwaccel_context;
-#endif /* HAVE_HWACCEL_NVIDIA */
uint16_t surface_id;
uint32_t codec_context_id;
uint32_t surface_serial;
@@ -212,7 +199,6 @@ grd_rdp_graphics_pipeline_delete_surface (GrdRdpGraphicsPipeline *graphics_pipel
GUINT_TO_POINTER (surface_serial));
}
-#ifdef HAVE_HWACCEL_NVIDIA
if (g_hash_table_steal_extended (graphics_pipeline->surface_hwaccel_table,
GUINT_TO_POINTER (surface_id),
NULL, (gpointer *) &hwaccel_context))
@@ -224,7 +210,6 @@ grd_rdp_graphics_pipeline_delete_surface (GrdRdpGraphicsPipeline *graphics_pipel
hwaccel_context->encode_session_id);
g_free (hwaccel_context);
}
-#endif /* HAVE_HWACCEL_NVIDIA */
if (g_hash_table_steal_extended (graphics_pipeline->codec_context_table,
GUINT_TO_POINTER (codec_context_id),
@@ -400,7 +385,6 @@ enqueue_tracked_frame_info (GrdRdpGraphicsPipeline *graphics_pipeline,
g_queue_push_tail (graphics_pipeline->encoded_frames, gfx_frame_info);
}
-#ifdef HAVE_HWACCEL_NVIDIA
static gboolean
refresh_gfx_surface_avc420 (GrdRdpGraphicsPipeline *graphics_pipeline,
HWAccelContext *hwaccel_context,
@@ -514,7 +498,6 @@ refresh_gfx_surface_avc420 (GrdRdpGraphicsPipeline *graphics_pipeline,
return TRUE;
}
-#endif /* HAVE_HWACCEL_NVIDIA */
static gboolean
rfx_progressive_write_message (RFX_MESSAGE *rfx_message,
@@ -895,10 +878,8 @@ grd_rdp_graphics_pipeline_refresh_gfx (GrdRdpGraphicsPipeline *graphics_pipeline
RdpgfxServerContext *rdpgfx_context = graphics_pipeline->rdpgfx_context;
rdpSettings *rdp_settings = rdpgfx_context->rdpcontext->settings;
GrdSessionRdp *session_rdp = graphics_pipeline->session_rdp;
-#ifdef HAVE_HWACCEL_NVIDIA
HWAccelContext *hwaccel_context;
uint16_t surface_id;
-#endif /* HAVE_HWACCEL_NVIDIA */
int64_t enc_time_us;
gboolean success;
@@ -920,7 +901,6 @@ grd_rdp_graphics_pipeline_refresh_gfx (GrdRdpGraphicsPipeline *graphics_pipeline
map_surface_to_output (graphics_pipeline, rdp_surface->gfx_surface);
}
-#ifdef HAVE_HWACCEL_NVIDIA
surface_id = grd_rdp_gfx_surface_get_surface_id (rdp_surface->gfx_surface);
if (rdp_settings->GfxH264 &&
g_hash_table_lookup_extended (graphics_pipeline->surface_hwaccel_table,
@@ -933,7 +913,6 @@ grd_rdp_graphics_pipeline_refresh_gfx (GrdRdpGraphicsPipeline *graphics_pipeline
&enc_time_us);
}
else
-#endif /* HAVE_HWACCEL_NVIDIA */
{
success = refresh_gfx_surface_rfx_progressive (graphics_pipeline, rdp_surface,
region, buffer, &enc_time_us);
diff --git a/src/grd-rdp-graphics-pipeline.h b/src/grd-rdp-graphics-pipeline.h
index 7ba1d6a5..c67aa108 100644
--- a/src/grd-rdp-graphics-pipeline.h
+++ b/src/grd-rdp-graphics-pipeline.h
@@ -41,10 +41,8 @@ GrdRdpGraphicsPipeline *grd_rdp_graphics_pipeline_new (GrdSessionRdp
void grd_rdp_graphics_pipeline_maybe_init (GrdRdpGraphicsPipeline *graphics_pipeline);
-#ifdef HAVE_HWACCEL_NVIDIA
void grd_rdp_graphics_pipeline_set_hwaccel_nvidia (GrdRdpGraphicsPipeline *graphics_pipeline,
GrdHwAccelNvidia *hwaccel_nvidia);
-#endif /* HAVE_HWACCEL_NVIDIA */
void grd_rdp_graphics_pipeline_create_surface (GrdRdpGraphicsPipeline *graphics_pipeline,
GrdRdpGfxSurface *gfx_surface);
diff --git a/src/grd-rdp-server.c b/src/grd-rdp-server.c
index 9f8b3efa..70e7fc74 100644
--- a/src/grd-rdp-server.c
+++ b/src/grd-rdp-server.c
@@ -28,11 +28,9 @@
#include <winpr/ssl.h>
#include "grd-context.h"
+#include "grd-hwaccel-nvidia.h"
#include "grd-session-rdp.h"
-#ifdef HAVE_HWACCEL_NVIDIA
-#include "grd-hwaccel-nvidia.h"
-#endif /* HAVE_HWACCEL_NVIDIA */
enum
{
@@ -51,9 +49,7 @@ struct _GrdRdpServer
guint cleanup_sessions_idle_id;
GrdContext *context;
-#ifdef HAVE_HWACCEL_NVIDIA
GrdHwAccelNvidia *hwaccel_nvidia;
-#endif /* HAVE_HWACCEL_NVIDIA */
};
G_DEFINE_TYPE (GrdRdpServer, grd_rdp_server, G_TYPE_SOCKET_SERVICE)
@@ -68,15 +64,12 @@ GrdRdpServer *
grd_rdp_server_new (GrdContext *context)
{
GrdRdpServer *rdp_server;
-#ifdef HAVE_HWACCEL_NVIDIA
GrdEglThread *egl_thread;
-#endif /* HAVE_HWACCEL_NVIDIA */
rdp_server = g_object_new (GRD_TYPE_RDP_SERVER,
"context", context,
NULL);
-#ifdef HAVE_HWACCEL_NVIDIA
egl_thread = grd_context_get_egl_thread (rdp_server->context);
if (egl_thread &&
(rdp_server->hwaccel_nvidia = grd_hwaccel_nvidia_new (egl_thread)))
@@ -88,10 +81,6 @@ grd_rdp_server_new (GrdContext *context)
g_debug ("[RDP] Initialization of CUDA failed. "
"No hardware acceleration available");
}
-#else
- g_message ("[RDP] RDP backend is built WITHOUT support for NVENC and CUDA. "
- "No hardware acceleration available");
-#endif /* HAVE_HWACCEL_NVIDIA */
return rdp_server;
}
@@ -139,10 +128,7 @@ on_incoming (GSocketService *service,
g_debug ("New incoming RDP connection");
if (!(session_rdp = grd_session_rdp_new (rdp_server, connection,
-#ifdef HAVE_HWACCEL_NVIDIA
- rdp_server->hwaccel_nvidia,
-#endif /* HAVE_HWACCEL_NVIDIA */
- 0)))
+ rdp_server->hwaccel_nvidia)))
return TRUE;
rdp_server->sessions = g_list_append (rdp_server->sessions, session_rdp);
@@ -187,9 +173,7 @@ grd_rdp_server_stop (GrdRdpServer *rdp_server)
g_clear_handle_id (&rdp_server->cleanup_sessions_idle_id, g_source_remove);
grd_rdp_server_cleanup_stopped_sessions (rdp_server);
-#ifdef HAVE_HWACCEL_NVIDIA
g_clear_object (&rdp_server->hwaccel_nvidia);
-#endif /* HAVE_HWACCEL_NVIDIA */
}
static void
@@ -238,9 +222,7 @@ grd_rdp_server_dispose (GObject *object)
g_assert (!rdp_server->cleanup_sessions_idle_id);
g_assert (!rdp_server->stopped_sessions);
-#ifdef HAVE_HWACCEL_NVIDIA
g_assert (!rdp_server->hwaccel_nvidia);
-#endif /* HAVE_HWACCEL_NVIDIA */
G_OBJECT_CLASS (grd_rdp_server_parent_class)->dispose (object);
}
diff --git a/src/grd-session-rdp.c b/src/grd-session-rdp.c
index 2cb16236..0435257c 100644
--- a/src/grd-session-rdp.c
+++ b/src/grd-session-rdp.c
@@ -31,6 +31,7 @@
#include "grd-clipboard-rdp.h"
#include "grd-context.h"
#include "grd-damage-utils.h"
+#include "grd-hwaccel-nvidia.h"
#include "grd-rdp-buffer.h"
#include "grd-rdp-damage-detector.h"
#include "grd-rdp-event-queue.h"
@@ -44,10 +45,6 @@
#include "grd-settings.h"
#include "grd-stream.h"
-#ifdef HAVE_HWACCEL_NVIDIA
-#include "grd-hwaccel-nvidia.h"
-#endif /* HAVE_HWACCEL_NVIDIA */
-
#define DISCRETE_SCROLL_STEP 10.0
typedef enum _RdpPeerFlag
@@ -150,9 +147,7 @@ struct _GrdSessionRdp
NSCThreadPoolContext nsc_thread_pool_context;
RawThreadPoolContext raw_thread_pool_context;
-#ifdef HAVE_HWACCEL_NVIDIA
GrdHwAccelNvidia *hwaccel_nvidia;
-#endif /* HAVE_HWACCEL_NVIDIA */
GSource *pending_encode_source;
@@ -1707,10 +1702,8 @@ rdp_peer_post_connect (freerdp_peer *peer)
rdp_peer_context->network_autodetection,
rdp_peer_context->encode_stream,
rdp_peer_context->rfx_context);
-#ifdef HAVE_HWACCEL_NVIDIA
grd_rdp_graphics_pipeline_set_hwaccel_nvidia (
rdp_peer_context->graphics_pipeline, session_rdp->hwaccel_nvidia);
-#endif /* HAVE_HWACCEL_NVIDIA */
}
grd_session_start (GRD_SESSION (session_rdp));
@@ -1980,18 +1973,14 @@ graphics_thread_func (gpointer data)
{
GrdSessionRdp *session_rdp = data;
-#ifdef HAVE_HWACCEL_NVIDIA
if (session_rdp->hwaccel_nvidia)
grd_hwaccel_nvidia_push_cuda_context (session_rdp->hwaccel_nvidia);
-#endif /* HAVE_HWACCEL_NVIDIA */
while (WaitForSingleObject (session_rdp->stop_event, 0) == WAIT_TIMEOUT)
g_main_context_iteration (session_rdp->graphics_context, TRUE);
-#ifdef HAVE_HWACCEL_NVIDIA
if (session_rdp->hwaccel_nvidia)
grd_hwaccel_nvidia_pop_cuda_context (session_rdp->hwaccel_nvidia);
-#endif /* HAVE_HWACCEL_NVIDIA */
return NULL;
}
@@ -1999,10 +1988,7 @@ graphics_thread_func (gpointer data)
GrdSessionRdp *
grd_session_rdp_new (GrdRdpServer *rdp_server,
GSocketConnection *connection,
-#ifdef HAVE_HWACCEL_NVIDIA
- GrdHwAccelNvidia *hwaccel_nvidia,
-#endif /* HAVE_HWACCEL_NVIDIA */
- int reserved)
+ GrdHwAccelNvidia *hwaccel_nvidia)
{
GrdSessionRdp *session_rdp;
GrdContext *context;
@@ -2032,9 +2018,7 @@ grd_session_rdp_new (GrdRdpServer *rdp_server,
NULL);
session_rdp->connection = g_object_ref (connection);
-#ifdef HAVE_HWACCEL_NVIDIA
session_rdp->hwaccel_nvidia = hwaccel_nvidia;
-#endif /* HAVE_HWACCEL_NVIDIA */
session_rdp->socket_thread = g_thread_new ("RDP socket thread",
socket_thread_func,
diff --git a/src/grd-session-rdp.h b/src/grd-session-rdp.h
index 49512c50..15b8bee7 100644
--- a/src/grd-session-rdp.h
+++ b/src/grd-session-rdp.h
@@ -41,10 +41,7 @@ typedef enum _GrdSessionRdpError
GrdSessionRdp *grd_session_rdp_new (GrdRdpServer *rdp_server,
GSocketConnection *connection,
-#ifdef HAVE_HWACCEL_NVIDIA
- GrdHwAccelNvidia *hwaccel_nvidia,
-#endif /* HAVE_HWACCEL_NVIDIA */
- int reserved);
+ GrdHwAccelNvidia *hwaccel_nvidia);
void grd_session_rdp_notify_error (GrdSessionRdp *session_rdp,
GrdSessionRdpError error_info);
diff --git a/src/meson.build b/src/meson.build
index ff1f2894..6f67cf39 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -47,6 +47,8 @@ if have_rdp
daemon_sources += files([
'grd-clipboard-rdp.c',
'grd-clipboard-rdp.h',
+ 'grd-hwaccel-nvidia.c',
+ 'grd-hwaccel-nvidia.h',
'grd-rdp-buffer.c',
'grd-rdp-buffer.h',
'grd-rdp-buffer-pool.c',
@@ -82,6 +84,8 @@ if have_rdp
])
deps += [
+ cuda_dep,
+ dl_dep,
freerdp_dep,
freerdp_client_dep,
freerdp_server_dep,
@@ -89,18 +93,6 @@ if have_rdp
winpr_dep,
xkbcommon_dep,
]
-
- if have_hwaccel_nvidia
- daemon_sources += files([
- 'grd-hwaccel-nvidia.c',
- 'grd-hwaccel-nvidia.h',
- ])
-
- deps += [
- cuda_dep,
- dl_dep,
- ]
- endif
endif
if have_vnc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]