Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dri3 and glamor #1029

Closed
jsorg71 opened this issue Feb 4, 2018 · 43 comments
Closed

dri3 and glamor #1029

jsorg71 opened this issue Feb 4, 2018 · 43 comments
Assignees

Comments

@jsorg71
Copy link
Contributor

jsorg71 commented Feb 4, 2018

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.

@jsorg71 jsorg71 self-assigned this Feb 4, 2018
@jsorg71
Copy link
Contributor Author

jsorg71 commented Feb 4, 2018

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

@paravz
Copy link

paravz commented May 7, 2018

do you need help, maybe in testing this ?

@jsorg71
Copy link
Contributor Author

jsorg71 commented May 7, 2018

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.

@paravz
Copy link

paravz commented Jun 10, 2018

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

@Nexarian
Copy link
Contributor

Nexarian commented Nov 2, 2019

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)

@jsorg71
Copy link
Contributor Author

jsorg71 commented Nov 3, 2019

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.

@Nexarian
Copy link
Contributor

Nexarian commented Nov 3, 2019

@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?

@jsorg71
Copy link
Contributor Author

jsorg71 commented Nov 15, 2019

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.

@claudenobs
Copy link

claudenobs commented Feb 1, 2020

--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?

uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Feb 27, 2020
With the advent of 1.20.x x11-server/xorg-server xorgxrdp can support
dri3/glamor [1] to enable hardware supported OpenGL acceleration with an
xorgxrdp desktop.

Also add pkg-message to explain how to enable hardware acceleration.

While here, fix misuse of "-I" flag to specify LIBDIR.

[1] neutrinolabs/xrdp#1029

PR:		244298
Submitted by:	Derek Schrock <[email protected]> (initial revision)
Approved by:	meta (myself, maintainer)
Sponsored by:	HAW International


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@527235 35697150-7ecd-e111-bb59-0022644237b5
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Feb 27, 2020
With the advent of 1.20.x x11-server/xorg-server xorgxrdp can support
dri3/glamor [1] to enable hardware supported OpenGL acceleration with an
xorgxrdp desktop.

Also add pkg-message to explain how to enable hardware acceleration.

While here, fix misuse of "-I" flag to specify LIBDIR.

[1] neutrinolabs/xrdp#1029

PR:		244298
Submitted by:	Derek Schrock <[email protected]> (initial revision)
Approved by:	meta (myself, maintainer)
Sponsored by:	HAW International
Jehops pushed a commit to Jehops/freebsd-ports-legacy that referenced this issue Feb 27, 2020
With the advent of 1.20.x x11-server/xorg-server xorgxrdp can support
dri3/glamor [1] to enable hardware supported OpenGL acceleration with an
xorgxrdp desktop.

Also add pkg-message to explain how to enable hardware acceleration.

While here, fix misuse of "-I" flag to specify LIBDIR.

[1] neutrinolabs/xrdp#1029

PR:		244298
Submitted by:	Derek Schrock <[email protected]> (initial revision)
Approved by:	meta (myself, maintainer)
Sponsored by:	HAW International


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@527235 35697150-7ecd-e111-bb59-0022644237b5
ericbsd pushed a commit to ghostbsd/ghostbsd-ports that referenced this issue Mar 7, 2020
With the advent of 1.20.x x11-server/xorg-server xorgxrdp can support
dri3/glamor [1] to enable hardware supported OpenGL acceleration with an
xorgxrdp desktop.

Also add pkg-message to explain how to enable hardware acceleration.

While here, fix misuse of "-I" flag to specify LIBDIR.

[1] neutrinolabs/xrdp#1029

PR:		244298
Submitted by:	Derek Schrock <[email protected]> (initial revision)
Approved by:	meta (myself, maintainer)
Sponsored by:	HAW International
@rkkoszewski
Copy link

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

@paravz
Copy link

paravz commented Apr 3, 2020

to configure script of xorgxrdp, when building from source

@steverweber
Copy link

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.

@rkkoszewski
Copy link

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).

@paravz
Copy link

paravz commented Apr 4, 2020

@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

@rkkoszewski
Copy link

rkkoszewski commented Apr 22, 2020

@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

@paravz
Copy link

paravz commented Apr 23, 2020

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

@paravz
Copy link

paravz commented Apr 26, 2020

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

@seamus-x
Copy link

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

@rkkoszewski
Copy link

rkkoszewski commented May 25, 2020

@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?

@2X3
Copy link

2X3 commented Jul 3, 2020

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

@lixaotec
Copy link

Any news on this?

Tried compiling.. also missin <gbm.h>

@lixaotec
Copy link

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

@lixaotec
Copy link

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

@Nexarian
Copy link
Contributor

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!

@lixaotec
Copy link

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

@rkkoszewski
Copy link

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)

@lixaotec
Copy link

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)

@sshaikh
Copy link

sshaikh commented Nov 8, 2020

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: #1029 (comment)

Any fix?

@sshaikh
Copy link

sshaikh commented Nov 9, 2020

I see similar errors here:

#1411
#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?

@MakiseKurisu
Copy link

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

@jat001
Copy link
Contributor

jat001 commented Apr 1, 2021

I see similar errors here:

#1411
#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?

After I made a package for xorgxrdp with glamor, I realized it does not work on nvidia gpu. however, feel free to test it.

@jat001
Copy link
Contributor

jat001 commented Apr 1, 2021

I see similar errors here:
#1411
#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?

After I made a package for xorgxrdp with glamor, I realized it does not work on nvidia gpu. however, feel free to test it.

I also made a package for xorgxrdp with nvidia and I can confirm that it works. thx @jsorg71 and @Nexarian

@sshaikh
Copy link

sshaikh commented Apr 1, 2021

@jat001 Thanks for this. I've passed some feedback on the aur page for the non nvidia PKGBUILD

@rcarmo
Copy link

rcarmo commented Oct 18, 2022

I've been trying to get this to work but once I've logged in, the screen remains with the sesman wallpaper and there is nothing in the logs - except a timeout, eventually:

[20221018-17:33:29] [INFO ] sesman connect ok
[20221018-17:33:29] [INFO ] sending login info to session manager. Please wait...
[20221018-17:33:29] [INFO ] xrdp_wm_log_msg: login successful for user me on display 10
[20221018-17:33:29] [INFO ] login successful for user me on display 10
[20221018-17:33:29] [INFO ] loaded module 'libxup.so' ok, interface size 10296, version 4
[20221018-17:33:29] [INFO ] started connecting
[20221018-17:33:29] [INFO ] lib_mod_connect: connecting via UNIX socket

Although I don't think that's necessary, I checked that my user is part of the video group (so I can access /dev/dri).

Anything obvious to look for in the logs, or debugging methods for the .so? If I revert to my distro's xorgxrdp package everything works fine.

@paravz
Copy link

paravz commented Oct 19, 2022

Check instructions from #1029 (comment), including X11 setup.

Check your glamor device name and if it's configured and working, ie:

$ lsgpu 
card0                    xxxx:xxxx                         drm:/dev/dri/card0
└─renderD128                                               drm:/dev/dri/renderD128

$ cat /etc/X11/xrdp/xorg.conf |grep render
    Option "DRMDevice" "/dev/dri/renderD128"

$ sudo journalctl -l --all -b |grep renderD128
Oct 18 22:45:42 dev xrdp-sesman[130071]: rdpProbe: found DRMDevice xorg.conf value [/dev/dri/renderD128]
Oct 18 22:45:42 dev xrdp-sesman[130071]: rdpPreInit: /dev/dri/renderD128 open ok, fd 12

@DocMAX
Copy link

DocMAX commented May 31, 2023

Can this be run headless? I mean with something like the Xvnc backend?

@rcarmo
Copy link

rcarmo commented May 31, 2023

It does run headless with the Xrdp backend. I have been using xorgxrdp-glamor (and equivalent packages shipping in Fedora, Ubuntu, etc.) for a long while now to get GPU-accelerated remote desktops. Sometimes it breaks (because of re-packaging issues, since not many people know about glamor, RFX, etc.), but when things are packaged "right", it is a very smooth experience. I only wish there was better debugging output (not just for glamor not working, but also including negotiated codecs).

@DocMAX
Copy link

DocMAX commented May 31, 2023

Testing the on Arch with AUR package xorgxrdp-glamor now.

@rcarmo
Copy link

rcarmo commented May 31, 2023

Make sure you edit /etc/xrdp/xrdp.ini to uncomment this section:

[Xorg]
name=Xorg
lib=libxup.so
username=ask
password=ask
ip=127.0.0.1
port=-1
code=20

(or equivalent) and make sure you select Xorg to login (or just disable VNC altogether). Also, client settings matter:

xfreerdp /gfx:rfx +gfx-progressive  /sound /dynamic-resolution /v:fedora.lan

@DocMAX
Copy link

DocMAX commented May 31, 2023

Awesome!!! It's working.
I was working with Xvnc before. Now i have fully GPU accelerated RDP. If only I had come across it earlier.

@rcarmo
Copy link

rcarmo commented May 31, 2023

I honestly don't know why Xrdp isn't the default, since it is faster than Xvnc even without glamor...

@DocMAX
Copy link

DocMAX commented May 31, 2023

Actually i noticed Xrdp is slower than Xvnc to me (opening Firefox for example takes longer, no idea why). But i stay on Xorg to have 3D.

@matt335672
Copy link
Member

I think this can now be closed as we've made it easier to use --enable-glamor.

See neutrinolabs/xorgxrdp#295, which is largely the work of @jat001.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests