Xrdp: dri3 and glamor

Created on 4 Feb 2018  Â·  30Comments  Â·  Source: neutrinolabs/xrdp

With DRI3, we can enable hardware OpenGL in xrdp sessions. DRI3 allows non root access to video hardware through render nodes(/dev/dri/renderD128).
With Glamor, we can use that hardware OpenGL to accelerate the 2D calls with pixels shaders.

work in progress

Most helpful comment

Looks like the glamor branch has been merged into xorgxrdp! That was a lot of work!

Can this work with Nvidia? I see provisions in the code for EGL streams (Nvidia's tech), but when I tried it, it's still using llvmpipe (software rendering) on Nvidia's binary drivers (Ubuntu 18.04)

All 30 comments

Here is a working prototype. This is Windows 10 mstsc connected to an xrdp ATI GPU server.
Showing the KDE desktop cube affect.
xrdp-glamor

do you need help, maybe in testing this ?

Sure, you can use glamor branch
https://github.com/jsorg71/xorgxrdp/tree/glamor
Make sure your Xorg is 1.19+ (Debian 9 or Ubuntu 18.04)
Should work with NVidia, ATI and Intel graphics as long as the open source drivers are used.
No change to xrdp yet, this is just changes to the Xorg driver.

Finally got around to test on fedora 28 with cinnamon. Basically works great on the first glance. As expected, significant reduction in CPU usage across the board - Thanks for this change!

The only issue connecting from win10 mstsc was blank screen depending on client's "connection type":

  • my client for xorgxrd-standard+Cinnamon with software rendering worked with: "connection type:i:7" (auto detect network settings).
  • Connecting to xorgxrdp-glamor with "connection type:i:7" results in black/blank screen in mstsc.
  • xorgxrdp-glamor+Cinnamon DRI3 requires "connection type:i:6" (LAN 10 Mbps).
  • xorgxrdp+Cinnamon software rendering works with "connection type:i:6" too. Basically i switched to "connection type:i:6" for xrdp systems

Looks like the glamor branch has been merged into xorgxrdp! That was a lot of work!

Can this work with Nvidia? I see provisions in the code for EGL streams (Nvidia's tech), but when I tried it, it's still using llvmpipe (software rendering) on Nvidia's binary drivers (Ubuntu 18.04)

Yes, it's merge in devel branch but off by default. --enable-glamor to turn it on.
The glamor module in Xorg only uses mesa currently. So it works with the nouveau driver on NVidia hardware. I know that's not optimal but we'll work on a solution. Currently have to recommend Intel or AMD hardware.

@jsorg71 That's great that you're working on a solution! Having XRDP work with the Nvidia accelerated ecosystem would unblock remoting scenarios in the Machine Learning Linux world (which is huge).

I am happy to test prototypes when the come out, and I can verify that it is perfectly stable with glamor enabled with Nvidia drivers, it just uses software rendering (which is important, too).

What does libepoxy and the EGL stream portion do?

I see this link about 'PRIME render offloading' that looks interesting. This is all really new and relies on xserver bits not yet released.

libepoxy is just a helper library for OpenGL.
https://github.com/anholt/libepoxy
rdpEGL.c is the custom pixel shades to do the RGB to YUV, CRC32, and other operations on the GPU.

--enable-glamor doesn't seem to be present in ubuntu 20.04 xrdp (release 0.9.12).

compiled from source. but there's still no --enable-glamor option... have things changed?
EDIT: there is, its a configure option for xorgxrdp. however now i'm missing gbm.h...
EDIT2: installed libgdm-dev but still no gbm.h... apt-file finds no package providing it.

also: does it work with xwayland or do i need x11?

Where do you put the --enable-glamor flag?

to configure script of xorgxrdp, when building from source

Sorry if not helpful.. A week or so ago I went to rebuild parts of the xrdp stack to test glamor on ubuntu20.04(pre release).. I then stopped after seeing the xorgxrdp package seemed to include glamoregl in: /etc/X11/xrdp/xorg.conf. After making an xrdp connection and running glxgears (seemed ok).. but that might just be software rendering seeing llvm glxinfo grep | llvmpipe.

Shrug some directions on how to get testing this would be helpful. I help manage some HPCs ~50 nvidia gpus. Would love to give the users hw accelerated glxgears over rdp.

Nice! It works! I can see the GPU usage in intel_gpu_top, and it seems to leverage the GPU really nicely (You can even watch videos and run graphical tasks), while the CPU is completely relaxed (It barely uses 3-5% of CPU on average).

But the frame-rate seems extremely low in XRDP. It looks like it's running at 5 to 10 FPS or so, no matter if moving windows around or watching a video. I had the same issues in software rendering mode previously. Is that normal? (I'm in LAN, tested with Experience "LAN 10Mbps" and all lower options, have set the minimum security to None in XRDP, and also tried with 16bit colors, all with the same result).

@rkkoszewski try changing xrdp.ini settings, specifically bitmap_compression bulk_compression and independently try "Detect automatically" instead of "LAN 10Mbs" in client settings

Disabling all compression and using "Detect automatically" should be best quality, with enormous bandwidth requirements - but i'm curious what will be your experience

@paravz Thank you for the suggestions. I tested every possible combination of bitmap_compression, bulk_compression and the "Detect automatically"/"LAN 10Mbs", but the results are nearly always the same. It does look that enabling bulk_compression makes it sligthly slower, but it might be placebo. The only difference was in bandwith usage. It still looks like it's running at a static 5 to 10 FPS.

One thing to note is that I'm running the desktop in an LXC container (Glamor is 100% working, as I can see the GPU load change when dragging windows). Tested also with Windows Native RDP client, as also with the open source aRDP client, all with same result. Setting the resolution to 800x600 seems to improve things (Both compressed and uncompressed), but again might be placebo, as the difference is minimal.

Any more ideas? How is it working for you? Is it possible to watch smoothly a video (even if it's just in a small window) trough xrdp?

Here is a log of xorgxrdp: https://gist.github.com/rkkoszewski/ff4cb6b90e20322b4791895319c0fc1c

1080p youtube video in firefox works smoothly for me in cinnamon, it might your hardware, kernel or something else

Interestingly my system uses different "X" drivers with i915 hardware, especially VDPAU for hardware video acceleration. I have not specifically tuned any of it, comes with 5.4.19 kernel

[925218.683] rdpDri2Init:
[925218.683] (II) XRDPDEV(0): [DRI2] Setup complete
[925218.683] (II) XRDPDEV(0): [DRI2]   DRI driver: i965
[925218.683] (II) XRDPDEV(0): [DRI2]   VDPAU driver: va_gl

@rkkoszewski Have you tried recompiling xrdp with --enable-rfxcodec and enable RemoteFX on the client?

@seamus-x I thought that option was enabled by default. Is there any way to check that it is indeed missing in my setup? I can't see anything rfx related in the logs I posted. Should it be there? Or somewhere else?

EDIT:
Checked in XRDP that RFX is enabled and working when I connect to with the client, but the framerate is still as slow as before.

EDIT 2:
I seem to have found the culprit. Disabling "Display Compositing" catapults glxgears from running at 15FPS to 50 to 55 FPS.. Could it be that the integrated GPU is not fast enough? It does go till 75% GPU usage with the compositor is ON and glxgears is running.. Without the compositor enabled it is around 20 to 25% of GPU usage with glxgears running at smooth 50+ FPS. Or is XRDP just not compatible with "Display Compositing" in Xfce?

In any case, I already tested disabling the "Display Compositor" before in XRDP with RFX and without glamor. With glamor enabled it's the first time that I see such framerate performance, so that's a huge success!! Thank you all for helping out!!

BTW: Is there any reason why the glamor changes are not enabled by default in XRDP?

Unfortunately this does not work for me on Manjaro. Is it possible that with --enable-glamor option different version of xorg-server is expected?

Errors in Xorg log

[1030848.611] (II) LoadModule: "xrdpdev"
[1030848.611] (II) Loading /usr/lib/xorg/modules/drivers/xrdpdev_drv.so
[1030848.611] (EE) Failed to load /usr/lib/xorg/modules/drivers/xrdpdev_drv.so: /usr/lib/xorg/modules/drivers/xrdpdev_drv.so: undefined symbol: rdpRRModeDestroy
[1030848.611] (EE) Failed to load module "xrdpdev" (loader failed, 0)
[1030848.611] (II) LoadModule: "xrdpmouse"
[1030848.611] (II) Loading /usr/lib/xorg/modules/input/xrdpmouse_drv.so
[1030848.611] (EE) Failed to load /usr/lib/xorg/modules/input/xrdpmouse_drv.so: /usr/lib/xorg/modules/input/xrdpmouse_drv.so: undefined symbol: rdpUnregisterInputCallback
[1030848.611] (EE) Failed to load module "xrdpmouse" (loader failed, 0)
[1030848.611] (II) LoadModule: "xrdpkeyb"
[1030848.611] (II) Loading /usr/lib/xorg/modules/input/xrdpkeyb_drv.so
[1030848.611] (EE) Failed to load /usr/lib/xorg/modules/input/xrdpkeyb_drv.so: /usr/lib/xorg/modules/input/xrdpkeyb_drv.so: undefined symbol: rdpUnregisterInputCallback
[1030848.611] (EE) Failed to load module "xrdpkeyb" (loader failed, 0)
[1030848.611] (EE) No drivers available.
[1030848.611] (EE) 
Fatal server error:
[1030848.611] (EE) no screens found(EE) 

Packages version

pacman -Q xrdp xorgxrdp-git xorg-server
xrdp 0.9.13-1
xorgxrdp-git 0.2.13-1
xorg-server 1.20.8-3

Any news on this?

Tried compiling.. also missin

ive installed libgbm-dev and libepoxy-dev, solved for make

however when i log xrdp, after inpu user and pass.. i get a blue (cyan?) screen only.. no go further

finally i managed to get it..
What is to be to to have NVidia Proprietary driver to works with it?

Nvidia is a bit tricky. @jsorg71 created a prototype branch that allows for direct hardware acceleration with Nvidia: https://github.com/jsorg71/xorgxrdp/tree/nvidia_hack

But it requires some setup:

  1. I couldn't get this to work with Gnome. I recommend using mate.
  2. You'll need to rebuild xorgxrdp and install it first.
  3. Find what PCI address your Nvidia card is on:
    lspci | grep NVIDIA
    It’ll look something like this:
    65:00.0 VGA compatible controller: NVIDIA Corporation GP104GL [Quadro P5000] (rev a1)
    That 65 value is the PCI bus address of your card.
    Convert that value to hexadecimal (easy to do with a Google search)
  4. Now, edit the new configuration file for the Nvidia specific setup: sudo vim /etc/X11/xrdp/xorg_nvidia.conf
  5. Change Line 38 to replace the ‘2’ with whatever hex value you obtained above
  6. Now, open up /etc/xrdp/sesman.ini and change the line that has param=xrdp/xrdp.conf to param=xorg_nvidia.conf — On my system this line is 89 but YMMV
  7. Restart xrdp: sudo service xrdp restart

Confirm it works by running glxgears.

Also note that this doesn't use virtualgl, it's directly integrated with the drivers!

Right now this is just a prototype and obviously the awkward setup and other issues such as Gnome compatibility need to be addressed, but it's a massive step in the right direction!

Thanks @Nexarian ! Will soon try and let all know.

Also would like to contribute with coding, despite the fact i dont know nothing on this, if manteiners could provide and describs what else is to be done and where to start i could try.

I think this is the only open tech nowadays that enables serius graphics remote working, without goingo to m$ world or online services

If somebody is struggling to install XRDP with GLAMOR enabled here are my notes on how to install it on a Debian 9: https://gist.github.com/rkkoszewski/aa531cee7126edf329b76bdd0546f502

A question for @jsorg71 : Is there any way to make VAAPI with Hardware acceleration to work in a XRDP session with GLAMOR enabled? From my tests and by using "strace" I can see that VAAPI is working, it is able to open the GPU render node, but then it checks for some "MAGIC" number that is different from the one it is expecting, and it defaults to software encoding/decoding. (I'll upload the log once I find it again)

If somebody is struggling to install XRDP with GLAMOR enabled here are my notes on how to install it on a Debian 9: https://gist.github.com/rkkoszewski/aa531cee7126edf329b76bdd0546f502

A question for @jsorg71 : Is there any way to make VAAPI with Hardware acceleration to work in a XRDP session with GLAMOR enabled? From my tests and by using "strace" I can see that VAAPI is working, it is able to open the GPU render node, but then it checks for some "MAGIC" number that is different from the one it is expecting, and it defaults to software encoding/decoding. (I'll upload the log once I find it again)

Is it thr same for Cinnamon (mint)

I'm having difficulty getting this running in Arch.

It compiles okay but then sesman throws an error when trying to create an x server:

[ERROR] X server for display 10 startup timeout
[CORE ] waiting for window manager (pid 804) to exit
[ERROR] X server for display 10 startup timeout
[ERROR] another Xserver might already be active on display 10 - see log
[CORE ] window manager (pid 804) did exit, cleaning up session

Any tips on how to debug this?

EDIT: I'm seeing the same issue as @2X3 here: https://github.com/neutrinolabs/xrdp/issues/1029#issuecomment-653665152

Any fix?

I see similar errors here:

https://github.com/neutrinolabs/xrdp/issues/1411
https://github.com/neutrinolabs/xrdp/issues/786

So it seems a bit of a hairy one and is now above my paygrade unfortunately.

Edit: fixed here: https://bbs.archlinux.org/viewtopic.php?pid=1937867#p1937867 by using the following configure:

CFLAGS+=" $(pkgconf --cflags libdrm)" LDFLAGS+=" -L/usr/lib/xorg/modules -lglamoregl -Wl,-rpath,/usr/lib/xorg/modules" ./configure \
    --prefix="/usr" -enable-glamor

Can this be used to fix something in the source?

glamor seems great and I really want to see this feature is enabled by default, or configurable at run time, not build time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vamsheerudra picture vamsheerudra  Â·  4Comments

joakim-tjernlund picture joakim-tjernlund  Â·  9Comments

AlexNikolaenko picture AlexNikolaenko  Â·  3Comments

Rubarius picture Rubarius  Â·  5Comments

Jerry-kiwi picture Jerry-kiwi  Â·  4Comments