Skip to content

Commit

Permalink
nvenc: add --enable-accel, change yami to va
Browse files Browse the repository at this point in the history
  • Loading branch information
jsorg71 committed Dec 5, 2024
1 parent f7c22d0 commit e6d3e52
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
8 changes: 7 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ else
ULALACADIR =
endif

if XRDP_ACCEL
ACCELDIR = xrdp_accel_assist
else
ACCELDIR =
endif

# This should not be dictionary order but build order
SUBDIRS = \
third_party \
Expand Down Expand Up @@ -71,7 +77,7 @@ SUBDIRS = \
$(ULALACADIR) \
tests \
tools \
xrdp_accel_assist
$(ACCELDIR)

distclean-local:
-rm -f xrdp_configure_options.h
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ AC_ARG_ENABLE(nvenc, AS_HELP_STRING([--enable-nvenc],
XRDP_NVENC_LIBS should be set if used]),
[], [enable_nvenc=no])
AM_CONDITIONAL(XRDP_NVENC, [test x$enable_nvenc = xyes])
AC_ARG_ENABLE(accel, AS_HELP_STRING([--enable-accel],
[Build xrdp_accel_assist (default: no, auto set if --enable-nvenc)]),
[], [enable_accel=no])
# AM_CONDITIONAL(XRDP_ACCEL, [test x$enable_accel = xyes]) later in this file
AC_ARG_ENABLE(painter, AS_HELP_STRING([--disable-painter],
[Do not use included painter library (default: no)]),
[], [enable_painter=yes])
Expand Down Expand Up @@ -509,6 +513,7 @@ AS_IF( [test "x$enable_openh264" = "xyes"] , [PKG_CHECK_MODULES(XRDP_OPENH264, o

if test "x$enable_nvenc" = "xyes"
then
enable_accel=$enable_nvenc
if test ! -z "$XRDP_NVENC_CFLAGS"
then
AC_SUBST(XRDP_NVENC_CFLAGS, ["$XRDP_NVENC_CFLAGS"])
Expand All @@ -519,6 +524,8 @@ then
fi
fi

AM_CONDITIONAL(XRDP_ACCEL, [test x$enable_accel = xyes])

# checking for TurboJPEG
if test "x$enable_tjpeg" = "xyes"
then
Expand Down Expand Up @@ -698,6 +705,7 @@ echo " rfxcodec $enable_rfxcodec"
echo " x264 $enable_x264"
echo " openh264 $enable_openh264"
echo " nvenc $enable_nvenc"
echo " accel $enable_accel"
echo " painter $enable_painter"
echo " pixman $enable_pixman"
echo " fuse $enable_fuse"
Expand Down
7 changes: 0 additions & 7 deletions xrdp_accel_assist/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ XRDP_EXTRA_LIBS += $(XRDP_NVENC_LIBS)
XRDP_EXTRA_SOURCES += xrdp_accel_assist_nvenc.c xrdp_accel_assist_nvenc.h encoder_headers/nvEncodeAPI_11_1.h
endif

if XRDP_YAMI
AM_CPPFLAGS += -DXRDP_YAMI
AM_CPPFLAGS += $(XRDP_YAMI_CFLAGS)
XRDP_EXTRA_LIBS += $(XRDP_YAMI_LIBS)
XRDP_EXTRA_SOURCES += xrdp_accel_assist_yami.c xrdp_accel_assist_yami.h encoder_headers/yami_inf.h
endif

pkglibexec_PROGRAMS = \
xrdp-accel-assist

Expand Down
25 changes: 7 additions & 18 deletions xrdp_accel_assist/xrdp_accel_assist_x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* Currently nvenc requires GLX because NVidia's EGL does not have
* EGL_NOK_texture_from_pixmap extension but NVidia's GLX does have
* GLX_EXT_texture_from_pixmap. We require one if those,
* also, yami required EGL because it used dma bufs.
* also, va required EGL because it used dma bufs.
* I do not think any vendor's GLX support dma bufs */
/* Things like render on one GPU and encode with another is possible
* but not supported now. */
Expand Down Expand Up @@ -57,10 +57,6 @@
#include "xrdp_accel_assist_nvenc.h"
#endif

#if defined(XRDP_YAMI)
#include "xrdp_accel_assist_yami.h"
#endif

/* X11 */
Display *g_display = NULL;
static int g_x_socket = 0;
Expand All @@ -70,7 +66,7 @@ Window g_root_window = None;
static Visual *g_vis = NULL;
static GC g_gc;

/* encoders: nvenc or yami */
/* encoders: nvenc or va */
struct enc_funcs
{
int (*init)(void);
Expand All @@ -85,14 +81,7 @@ struct enc_funcs
static struct enc_funcs g_enc_funcs[] =
{
{
#if defined(XRDP_YAMI)
xrdp_accel_assist_yami_init,
xrdp_accel_assist_yami_create_encoder,
xrdp_accel_assist_yami_delete_encoder,
xrdp_accel_assist_yami_encode
#else
NULL, NULL, NULL, NULL
#endif
},
{
#if defined(XRDP_NVENC)
Expand Down Expand Up @@ -135,13 +124,13 @@ static struct inf_funcs g_inf_funcs[] =
};

/* 0 = EGL, 1 = GLX */
/* 0 = yami, 1 = nvenc */
/* 0 = va, 1 = nvenc */
#define INF_EGL 0
#define INF_GLX 1
#define ENC_YAMI 0
#define ENC_VA 0
#define ENC_NVENC 1
static int g_inf = INF_EGL;
static int g_enc = ENC_YAMI;
static int g_enc = ENC_VA;

struct mon_info
{
Expand Down Expand Up @@ -276,7 +265,7 @@ xrdp_accel_assist_x11_init(void)
else
{
g_inf = INF_EGL;
g_enc = ENC_YAMI;
g_enc = ENC_VA;
if (g_inf_funcs[g_inf].init() != 0)
{
LOG(LOG_LEVEL_ERROR, "xrdp_accel_assist_x11_init: "
Expand Down Expand Up @@ -672,7 +661,7 @@ xrdp_accel_assist_x11_create_pixmap(int width, int height, int magic,
mi->viewport.w = width;
mi->viewport.h = height * 3 / 2;
}
else if (g_enc == ENC_YAMI)
else if (g_enc == ENC_VA)
{
LOG(LOG_LEVEL_INFO, "xrdp_accel_assist_x11_create_pixmap: "
"using XH_YUV422");
Expand Down

0 comments on commit e6d3e52

Please sign in to comment.