ivan-hc / ArchImage

Build AppImage packages for all distributions but including Arch Linux packages. Powered by JuNest.
GNU General Public License v3.0
111 stars 1 forks source link

3D hardware acceleration? #20

Open kenderipa opened 6 months ago

kenderipa commented 6 months ago

Hello again,

I'm trying to build a Lutris AppImage. After building and l;aunching, it has following output:

Vulkan is not available or your system isn't Vulkan capable

Vulkan is, of course, installed on my system. How do I expose it for the AppImage (it probably tries to call vulkaninfo).

ivan-hc commented 6 months ago

Hi, this is a (sad) known issue... and a work in progress, see https://github.com/fsquillace/junest/issues/344

Latelly I discovered that by installing libselinux (from AUR, in the AppImage... you need to enable $BASICSTUFF, $COMPILERS and the AUR key) and by adding the following line into the AppRun (before "EXEC=")...

export LD_LIBRARY_PATH=/lib/:/lib64/:/lib/x86_64-linux-gnu/:/usr/lib/:"${LD_LIBRARY_PATH}"'

something changes in the output messages.

However, I've not done furter experiments about this.

Would you try by yourself?

ivan-hc commented 6 months ago

Right now I've tried to build SuperTuxKart by adding libselinux in "DEPENDENCES" and the line above in the AppRun, this is the message I have:

..:: Antarctica Rendering Engine 2.0 ::..
[info   ] [IrrDriver Logger]: ..:: Antarctica Rendering Engine 2.0 ::..
[info   ] [IrrDriver Logger]: Could not initialize display!
[info   ] [IrrDriver Logger]: ..:: Antarctica Rendering Engine 2.0 ::..
[info   ] [IrrDriver Logger]: Could not initialize display!
[info   ] [IrrDriver Logger]: ..:: Antarctica Rendering Engine 2.0 ::..
[info   ] [IrrDriver Logger]: Could not initialize display!
[info   ] [IrrDriver Logger]: ..:: Antarctica Rendering Engine 2.0 ::..
[info   ] [IrrDriver Logger]: Could not initialize display!
[fatal  ] irr_driver: Couldn't initialise irrlicht device. Quitting.
ivan-hc commented 6 months ago

NOTE: without "libselinux" installed into the AppImage, exporting LD_LIBRARY_PATH is useless and destructive... the AppImage would not run at all. In some way, "libselinux" helps to run both the libraries from the AppImage and from the host.

ivan-hc commented 6 months ago

UPDATE: also "libOpenGL libEGL libGLdispatch" must be included in "LIBSAVED="

ivan-hc commented 6 months ago

UPDATE: I've included also "libX11.so" in "LIBSAVED=" and I have several errors like this

/lib/libX11.so.6: error: symbol lookup error: undefined symbol: _XIFreeDeviceInfo (fatal)

I can't see the bottom, the messages are too long for my terminal

ivan-hc commented 6 months ago

UPDATE: I've included "libX" insead of "libX11.so" in "LIBSAVED=" and I have several errors related to all libraries libX* in the AppImage, like this

/lib/libX*: error: symbol lookup error: undefined symbol: _XIFreeDeviceInfo (fatal)

again, I can't see the bottom, the messages are too long for my terminal

ivan-hc commented 6 months ago

UPDATE: in first I've included all libraries in /usr/lib, the game starts but not the gameplay

Then I've execute directly the whole JuNest without removals... same result.

So, I think that here the issue is to use "--bind" to let the AppImage use libraries from the host... or at least LD_PRELOAD

@kenderipa if you want to test this, I'll resume the lines you must change in the script:

From here, I can't see furter improvements.

I hope you are luckier. Have fun.

EDIT: there could be fewer steps (the AUR related ones) if only "libselinux" was included by default in the AUR repositories (or in JuNest)

ivan-hc commented 6 months ago

@kenderipa see https://github.com/ivan-hc/ArchImage/commit/fa7c6f698e4efc1b746ad1c9a14560491731054a

From now all you need is:

all our tests can be done like this.

kenderipa commented 6 months ago

@kenderipa see fa7c6f6

From now all you need is:

* Line 6, "DEPENDENCES=" must include "`libselinux`"

* Line 243, "LIBSAVED=" must include `libOpenGL libEGL libGLdispatch libX` ...

all our tests can be done like this.

Thanks! I'll test it during the week. Don't have much time at the moment.

ivan-hc commented 6 months ago

In the meantime the AppImages are Type3: no libfuse2 is needed on the host

kenderipa commented 6 months ago

Interestingly, 3D acceleration works for ScummVm out of the box.

ivan-hc commented 6 months ago

Does ScummVm requiring GL accelleration?

I know that 32bit games in WINE work quite well, also without these implementations. Maybe you're wrong.

kenderipa commented 6 months ago

Does ScummVm requiring GL accelleration?

I know that 32bit games in WINE work quite well, also without these implementations. Maybe you're wrong.

That I may be, but I'm pretty sure that Longest Journey, a 3D game, with an enhanced texture pack requires at least OpenGL. Also, I can switch on OpenGL for ScummVM GUI. Only v-sync doesn't seem to work.

ivan-hc commented 6 months ago

What GPU? I've an old Nvidia (so I'm pretty sure that it would not work for me out of the box)

ivan-hc commented 6 months ago

Also you should see if your AppImage's /usr/lib/dri contains all drivers or just "swrast_dri.so"... or nothing.

If nothing or just "swrast_dri.so" is better.

kenderipa commented 6 months ago

What GPU? I've an old Nvidia (so I'm pretty sure that it would not work for me out of the box)

1660 Ti

ivan-hc commented 6 months ago

Can you do a test with SuperTuxKart?

kenderipa commented 6 months ago

Can you do a test with SuperTuxKart?

Sure, in the next few days.

ivan-hc commented 6 months ago

Steps I've done (for supertuxkart)

No audio, no gameplay... just menus and loading screen

kenderipa commented 6 months ago

So, Supertuxkart doesn't work for me, I have an endless loading screen.

ivan-hc commented 6 months ago

Its the same for me, we need to found the reason because the game does not starts.

Try to run the AppImage using LD_DEBUG https://bnikolic.co.uk/blog/linux-ld-debug.html

ivan-hc commented 6 months ago

@kenderipa maybe you're right. Maybe there is an issue only with SupertuxKart (we miss something in the bundle).

I've built the old car race game Torcs and works! I'll publish the new repo soon (just the time to fix missing audio issue).

EDIT: https://github.com/ivan-hc/Torcs-appimage

Just the time that this workflow run has finished.

@fsquillace this is really interesting.

Here we go!

https://github.com/ivan-hc/Torcs-appimage/releases/download/continuous/TORCS_1.3.7-6-archimage3.4-x86_64.AppImage

kenderipa commented 6 months ago

@kenderipa maybe you're right. Maybe there is an issue only with SupertuxKart (we miss something in the bundle).

I've built the old car race game Torcs and works! I'll publish the new repo soon (just the time to fix missing audio issue).

I've built Astromenace and 0 A. D., they both run very slowly, about 5-10 FPS.

ivan-hc commented 6 months ago

I've built Astromenace and 0 A. D., they both run very slowly, about 5-10 FPS.

you should run them using LD_DEBUG=libs

ivan-hc commented 6 months ago

@kenderipa I've tried to install 0ad and got this error

WARNING: You are using 'llvmpipe (LLVM 17.0.6, 256 bits)' graphics driver, expect very poor performance!

I've done a search and found this https://wiki.archlinux.org/title/OpenGL

EDIT: also including mesa in "DEPENDENCES" does not take the required effect, so we have not to "bloat" the content of /usr/lib/dri. All depends on "llvmpipe"

ivan-hc commented 6 months ago

This is the script I wrote for "0AD" 0ad-junest.txt (I had to rename it to .txt file because github does not allow .sh formats)

@andy5995 I'd like to have you in this Team, you're the expert of drivers support for this game

If you already had experienced with Archimages, all you have to do is to run the script I wrote to have a 1,8 GB AppImage of the "0AD" game, but we have an issue here to made it work with the host's drivers (being Archimage a Arch Linux container into an AppImage... we are trying to made it use the drivers of the host system).

andy5995 commented 6 months ago

@ivan-hc I'm no expert regarding the drivers but thank you for the compliment.

The way I worked around this with the 0ad AppImage was build one using Ubuntu 22.04 (Jammy). With no changes to how I built the AppImage, the image detected Vulkan whereas the image built on Ubuntu 20.04 (focal) did not (see the link above for more details).

ivan-hc commented 6 months ago

@andy5995 sure, I remember this detail about the two different versions of Ubuntu.

In this case, Archimages are able to work also on old dritributions with at least the Linux kernel v2.6 (so distributions of 10 years ago or more).

The only thing this kind of packaging lacks is support for GPU accelleration, due to its container's nature.

However, to include the changes we are discovering in this issue, we are near to a solution.

In this example, 0ad runs and works but with a very low performaces and about 5-10 FPS... we have this message in the terminal (and on the UI):

WARNING: You are using 'llvmpipe (LLVM 17.0.6, 256 bits)' graphics driver, expect very poor performance!

Now, two would be the solutions:

Now, the responsible of the drivers is "libLLVM-17.so" in /usr/lib (into the AppImage) that asks for "swrast_dri.so" in /usr/lib/dri (always inside the AppImage).

We need a way to use our drivers on the host instead of let the AppImage rely on what its bundled into it.

ivan-hc commented 3 months ago

Just experienced that this issue only affects systems with proprietary Nvidia drivers, I've tried this in some Kde games at https://github.com/ivan-hc/KDE-games-suite-appimage/issues/3 and in a pure Archimage-based Bottles version (not the hybrid one I've published, mixing Arch Linux + Debian).

3D gamse will work with Nouveau enabled, not with Nvidia propriatary drivers.

ivan-hc commented 3 months ago

@kenderipa how can I force an app using "nouveau" drivers instead of "nvidia"?

kenderipa commented 3 months ago

@kenderipa how can I force an app using "nouveau" drivers instead of "nvidia"?

No idea. You can, of course, uninstall the nVidia drivers and reinstall them again.

ivan-hc commented 3 months ago

@kenderipa how can I force an app using "nouveau" drivers instead of "nvidia"?

No idea. You can, of course, uninstall the nVidia drivers and reinstall them again.

its not a solution, but a workaroun... like the one I proposed.

No progresses in these months on this issue.

Samueru-sama commented 3 months ago

aisap binds the following to allow access to the GPU, maybe one of these is missing?

/sys/devices/pci000:00
/dev/nvidiactl
/dev/nvidia0
qurious-pixel commented 2 months ago

I was also trying to work this out, as this was the last thing I was stuck on, specifically for OBS using nVidia hardware acceleration. I had tested some theories, but they did not work out in the end. Back to the beginning.

ivan-hc commented 2 months ago

@qurious-pixel JuNest, and Archimages in general, use theiir internal copy of Bubblewrap to mount directories from the host system.

This is how the AppRun works in the latest version of my Archimages:

#!/bin/sh
HERE="$(dirname "$(readlink -f $0)")"
export UNION_PRELOAD=$HERE
export JUNEST_HOME=$HERE/.junest
export PATH=$PATH:$HERE/.local/share/junest/bin

if test -f /etc/resolv.conf; then ETC_RESOLV=' --bind /etc/resolv.conf /etc/resolv.conf '; fi
if test -d /media; then MNT_MEDIA_DIR=' --bind /media /media '; fi
if test -d /mnt; then MNT_DIR=' --bind /mnt /mnt '; fi
if test -d /opt; then OPT_DIR=' --bind /opt /opt '; fi
if test -d /run/user; then USR_LIB_LOCALE_DIR=' --bind /usr/lib/locale /usr/lib/locale '; fi
if test -d /usr/share/fonts; then USR_SHARE_FONTS_DIR=' --bind /usr/share/fonts /usr/share/fonts '; fi
if test -d /usr/share/themes; then USR_SHARE_THEMES_DIR=' --bind /usr/share/themes /usr/share/themes '; fi

BINDS=" $ETC_RESOLV $MNT_MEDIA_DIR $MNT_DIR $OPT_DIR $USR_LIB_LOCALE_DIR $USR_SHARE_FONTS_DIR $USR_SHARE_THEMES_DIR "

if test -f $JUNEST_HOME/usr/lib/libselinux.so; then export LD_LIBRARY_PATH=/lib/:/lib64/:/lib/x86_64-linux-gnu/:/usr/lib/:"${LD_LIBRARY_PATH}"; fi

EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e 's|%.||g')
$HERE/.local/share/junest/bin/junest -n -b "$BINDS" -- $EXEC "$@"

where "$BINDS" are all mountpoints.

For example, "$USR_SHARE_THEMES_DIR" is --bind /usr/share/themes /usr/share/themes, in a normal JuNest installation it would appear like this, to launch (for example) "obs"

junest -n -b " --bind /usr/share/themes /usr/share/themes " -- obs

with this command you use "junest" to launch "obs", and the internal Bubblewrap "-b" mounts the "/usr/share/themes" of the host in the guest Arch Linux container.

The directory "/usr/share/themes" must exist in both, host and guest.

Once we mount the exact files and directories from the host into the guest, we solve this issue.

But as you can see, this is an issue opened from months, without significative progresses.