xDoge26 / proot-setup

67 stars 13 forks source link

Request for Adreno 7xx series support and DRI3 support #26

Open hansm629 opened 1 year ago

hansm629 commented 1 year ago

Hello. I am using Termux-X11 PRoot-Distro Ubuntu 22.04 LTS XFCE4-SESSION 4.18 for my Galaxy S23 Ultra (Adreno 740) and Galaxy Tab S8+ 5G (Adreno 730).

I installed mesa-vulkan-kgsl_23.3.0-devel-20230803_arm64.deb that you build, and I found that it did not work.

As it works well with the Galaxy S20 (Adreno 650) PRoot, it does not appear that the currently built package supports the Adreno 7xx series.

Recently, freedreno turnip for the Termux package supports DRI3 as a patch, which seems to work with Turnip without inputting the MESA_VK_WSI_DEBUG=sw environment variable and perform better.

I request Adreno 7xx series support and DRI3 patching for the turnip package for PRoot.

hansm629 commented 10 months ago

@MastaG @Verycuteabbey

스크린샷_2023-12-27_20-55-17

There is also a way to run an xfce4 session as virgl. Easier than gl4es.

Verycuteabbey commented 10 months ago

@MastaG @Verycuteabbey

스크린샷_2023-12-27_20-55-17

There is also a way to run an xfce4 session as virgl. Easier than gl4es.

It's much simpler, but virglrenderer does not support DRI3

at performance, GL4ES better than it at rendering compatibility, virglrenderer more better

which is better choice, depend on you

MastaG commented 10 months ago

Indeed I'd rather use the native Turnip driver with Zink for OpenGL/OpenGLES as this will give the best performance.

However due to the MESA: error: kopper: could not create texture from pixmap error that happens when starting a desktop environment (Gnome, XFCE and even KDE) using Zink's OpenGL driver its best to use Zink's OpenGLES driver if your desktop supports it. Gnome does so by setting CLUTTER_DRIVER=gles2. Otherwise you can use GL4ES which will expose OpenGL on top of Zink's OpenGLES implementation, which should do the trick. However GL4ES only does limited OpenGL 2.x.

hansm629 commented 10 months ago

@Verycuteabbey

When running xfce4 with gl4es Does it provide better GUI performance compared to virgl(GALLIUM_DRIVER=virpipe)?

I'm curious if there is a way to run an xfce4 session with gl4es.

git clone https://github.com/ptitSeb/gl4es
cd gl4es
apt install -y gcc build-essential cmake libx11-dev
mkdir build; cd build; cmake -S ../../gl4es; make install

After compiling gl4es as above, How can I apply it to xfce4?

#!/bin/sh
killall -9 termux-x11 pulseaudio virgl_test_server_android
termux-wake-lock; termux-toast "Starting Debian Liunx"

# Termux-X11 start
am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity
df | grep /storage | cut -d "/" -f 4-

# X11 start
XDG_RUNTIME_DIR=${TMPDIR} termux-x11 :0 -ac -extension MIT-SHM &
virgl_test_server_android &
sleep 3

# Audio server
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1

# Linux login
touch ~/something
proot-distro login --bind ~/something:/proc/bus/pci/devices debian --user hsm --shared-tmp --no-sysvipc -- bash -c "export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1:4713; MESA_NO_ERROR=1 GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.6COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 dbus-launch --exit-with-session startxfce4"

My proot Debian run script is above.

@MastaG

How do I get xfce4 to run through Zink's OpenGL ES driver?

Is there any improvement in GUI performance compared to the existing virgl?

MastaG commented 10 months ago

@hansm629 I don't know if XFCE4 supports OpenGLES but Gnome does by setting CLUTTER_DRIVER=gles2 and launching Termux-X11 with -extension MIT-SHM.

Also I've never used Virgl before.

But as @xDoge26 mentioned before. You can use GL4ES to provide OpenGL on top of Zink's GLES implementation, which should be enough for running XFCE4.

So it's basically Turnip (native Adreno Vulkan driver) -> Zink (provides OpenGL and OpenGLES on top of turnip Vulkan driver) -> GL4ES (provides limited OpenGL 2.x on top of Zink's OpenGLES implementation).

The reason why we use GL4ES for OpenGL instead of Zink's own OpenGL 4.x implementation, is because most users are unable to use the latter for starting a desktop environment. You'll get the MESA: error: kopper: could not create texture from pixmap when starting it with Zink's OpenGL directly. I think this is due to some userspace limitation when running it within Termux' proot and/or due to the heavily outdated kernels that most Android phones ship. Because the Mesa issue for this error only mentions Android users running Zink on Termux-X11

However once you have your desktop loaded using GL4ES, you can of course use Zink's OpenGL or Turnip for Vulkan for your favourite games and apps.

hansm629 commented 10 months ago

@MastaG @Verycuteabbey

I just built gl4es and ran an xfce4 session with the environment variables below.

MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform MESA_GL_VERSION_OVERRIDE=4.6COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 LD_LIBRARY_PATH=/path/to/gl4es dbus-launch --exit-with-session startxfce4

스크린샷_2023-12-29_01-03-11

As a result, we confirmed that the program runs well through turnip+zink in the terminal without any additional environment variables.

however...

스크린샷_2023-12-29_00-58-15

For programs that recommend OpenGL3.3 or higher (ex: Blender, Kdenlive) We confirmed that it cannot be executed because it is an OpenGL ES2.0 backend.

Even if I entered the zink-related environment variables, the result was the same.

In my opinion, in the case of gl4es Compared to virgl, there is no particular improvement in GUI performance (same).

Due to an EGL backend problem, it is not compatible with the OpenGL 3.3 recommended program and cannot even be forced to run, which seems fatal. (Is there a way to force it to run? Even if I entered environment variables, execution was not possible.)

First of all, I run xfce4 with virgl. I think it would be better to manually apply the zink environment variable to each program, including the terminal....

MastaG commented 10 months ago

@hansm629 GL4ES is very limited and does not provide OpenGL 3.x or higher.

You started XFCE4 with GL4ES which is nice. However from the log I can see that Blender is using libGL from GL4ES as well. What happens if you use Zink's libGL instead?

Verycuteabbey commented 10 months ago

@MastaG @Verycuteabbey

I just built gl4es and ran an xfce4 session with the environment variables below.

MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform MESA_GL_VERSION_OVERRIDE=4.6COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 LD_LIBRARY_PATH=/path/to/gl4es dbus-launch --exit-with-session startxfce4

스크린샷_2023-12-29_01-03-11

As a result, we confirmed that the program runs well through turnip+zink in the terminal without any additional environment variables.

however...

스크린샷_2023-12-29_00-58-15

For programs that recommend OpenGL3.3 or higher (ex: Blender, Kdenlive) We confirmed that it cannot be executed because it is an OpenGL ES2.0 backend.

Even if I entered the zink-related environment variables, the result was the same.

In my opinion, in the case of gl4es Compared to virgl, there is no particular improvement in GUI performance (same).

Due to an EGL backend problem, it is not compatible with the OpenGL 3.3 recommended program and cannot even be forced to run, which seems fatal. (Is there a way to force it to run? Even if I entered environment variables, execution was not possible.)

First of all, I run xfce4 with virgl. I think it would be better to manually apply the zink environment variable to each program, including the terminal....

GL4ES only support OpenGL 1.1/2.1 to OpenGL ES implementation, so if you running program with problem just set the environment back to /usr/lib at startup, like sublime text:

2023-12-29_09-16

setting back the environment is equivalent to using Zink's OpenGL implementation

MastaG commented 10 months ago

So just out of curiosity, are the patches from dri.zip meant to go into upstream mesa? Who is the original author? And are they maintained somewhere for applying on more recent git snapshots? For example if I compile turnip from vanilla mesa git with freedreno-kmds=msm,kgsl will I also get dri3 support when not applying the patches?

hansm629 commented 10 months ago

@MastaG

No, the Termux DRI3 patch history is not reflected in mesa git. The DRI3 patch must still be applied when building Turnip.

The Termux DRI3 patch for Turnip was created by xMeM (https://github.com/xMeM).

If it's the way it was https://github.com/xMeM/termux-packages/tree/master/packages/mesa

There was a DRI3 patch in the path above, but it seems to have been deleted now.

hansm629 commented 10 months ago

@Verycuteabbey

After creating the script, do I have to enter it manually every time I need to use OpenGL?

Is there a way to force it to apply in "~/.profile" or "~/.bashrc"?

MastaG commented 9 months ago

@MastaG

No, the Termux DRI3 patch history is not reflected in mesa git. The DRI3 patch must still be applied when building Turnip.

The Termux DRI3 patch for Turnip was created by xMeM (https://github.com/xMeM).

If it's the way it was https://github.com/xMeM/termux-packages/tree/master/packages/mesa

There was a DRI3 patch in the path above, but it seems to have been deleted now.

Thx for the heads-up. So if you want to build mesa with the dri3 patch for the Adreno 700 series, can I just use mesa git with the patches from dri3.zip? Or do the 700 series still rely on this modified fork https://gitlab.freedesktop.org/Danil/mesa/-/archive/turnip/feature/a7xx-basic-support/mesa-turnip-feature-a7xx-basic-support.tar.gz ?

hansm629 commented 9 months ago

@MastaG No, the Termux DRI3 patch history is not reflected in mesa git. The DRI3 patch must still be applied when building Turnip. The Termux DRI3 patch for Turnip was created by xMeM (https://github.com/xMeM). If it's the way it was https://github.com/xMeM/termux-packages/tree/master/packages/mesa There was a DRI3 patch in the path above, but it seems to have been deleted now.

Thx for the heads-up. So if you want to build mesa with the dri3 patch for the Adreno 700 series, can I just use mesa git with the patches from dri3.zip? Or do the 700 series still rely on this modified fork https://gitlab.freedesktop.org/Danil/mesa/-/archive/turnip/feature/a7xx-basic-support/mesa-turnip-feature-a7xx-basic-support.tar.gz ?

@MastaG

I'm still build mesa Turnip using the DRI3 patch.

Turnip applied the DRI3 patch to the branch that supports Adreno750 and built it as a deb package.

https://gitlab.freedesktop.org/Danil/mesa/-/tree/feature/turnip/a750

I recently purchased the Galaxy S24 Ultra. forward to the performance of PRoot Debian running on Snapdragon 8 Gen3.

mesa-vulkan-kgsl_24.1.0-devel-20240120_arm64.deb

MastaG commented 9 months ago

Thank you @hansm629 for the information.

Yeah I was already browsing the branches of Danil's mesa fork. It seems the a7xx-basic-support branch has already been merged with upstream mesa.

You're correct as he is now working on Adreno 750 (Snapdragon 8 Gen3) support in his a750 branch. So if you have a Galaxy S24 or some other SD8Gen3 device, you should use his a750 branch until it's merged upstream. Otherwise you can just use mesa main git.

Btw do you only apply the wsi-termux-x11-v3.patch patch or do you also replace the wsi_common_x11.c file with the one from dri.zip? Because if I diff between wsi_common_x11.c from dri.zip and the one from mesa git, I don't see any noteworthy changes?

It bothers me a bit that xMeM wrote the DRI3 implementation for mesa and then deleted everything without bothering to send it upstream for review. I hope that somebody with more knowledge of the DRI3 implementation can update the patch and rebase it for us, leaving only the bare minimum changes for DRI3 support.

hansm629 commented 9 months ago

Thank you @hansm629 for the information.

Yeah I was already browsing the branches of Danil's mesa fork. It seems the a7xx-basic-support branch has already been merged with upstream mesa.

You're correct as he is now working on Adreno 750 (Snapdragon 8 Gen3) support in his a750 branch. So if you have a Galaxy S24 or some other SD8Gen3 device, you should use his a750 branch until it's merged upstream. Otherwise you can just use mesa main git.

Btw do you only apply the wsi-termux-x11-v3.patch patch or do you also replace the wsi_common_x11.c file with the one from dri.zip? Because if I diff between wsi_common_x11.c from dri.zip and the one from mesa git, I don't see any noteworthy changes?

It bothers me a bit that xMeM wrote the DRI3 implementation for mesa and then deleted everything without bothering to send it upstream for review. I hope that somebody with more knowledge of the DRI3 implementation can update the patch and rebase it for us, leaving only the bare minimum changes for DRI3 support.

@MastaG Although the project has been put on hold for a while now,

A talented developer active on Reddit Load the Android host Vulkan driver into Termux We are developing GPU acceleration by implementing X11 WSI in software and combining it with mesa-zink.

The talented person in question had a full-time job, so he was put on hold for a while. he said the project has not been halted.

It seems like quite a few parts have been implemented and only debugging remains. Ultimately, it seems that the goal is higher performance than virgl and better than turnip DRI3.

If developed well, it is expected that GPU acceleration will be possible in PRoot with the Android host Vulkan driver by symbolically linking the Vulkan library to PRoot in Termux.

MastaG commented 8 months ago

airidosas252 is pushing precompiled turnip builds on telegram with various wip MR's applied. https://t.me/airidosas252builds

chris-mcdonald-dev commented 8 months ago

@MastaG

You're correct as he is now working on Adreno 750 (Snapdragon 8 Gen3) support in his a750 branch. So if you have a Galaxy S24 or some other SD8Gen3 device, you should use his a750 branch until it's merged upstream. Otherwise you can just use mesa main git.

I think I've spent at least a week trying to figure out why this wasn't working properly on a 750 for me 😅

So to summarize (let me know if anything seems off if you don't mind!):

If you have an Adreno 6xx/7xx device

  1. Install a Linux distro with proot in Termux.
  2. Install the latest Termux-X11 app from the GitHub releases page since it supports DRI3.
  3. Download one of the pre-built drivers hansm629 has shared to your proot linux distro (or build it yourself using the commands below)
  4. Inside of your linux distro, install the mesa-vulkan-drivers package you just downloaded (this includes the Turnip driver).

If you have an Andreno 750 device (for now)

  1. Do steps 1-2 from above.
  2. Clone the mesa project branch Danylo is still working on to potentially get the most reliable dri3 support fir 750 GPUs a. this looks like the one they're currently working on
  3. Apply the patch from dri.zip by doing the following: a. Place wsi-termux-x11-v3.patch in sources dir and execute git apply -v wsi-termux-x11-v3.patch
  4. Build and compile the mesa driver yourself by following the pre-requisite instructions in Mesa's Compiling Docs and using the following commands when building:
    mkdir build
    meson -C build -Dgbm=enabled -Dopengl=true -Degl=enabled -Degl-native-platform=x11 -Dgles1=disabled -Dgles2=enabled -Ddri3=enabled -Dglx=dri -Dllvm=enabled -Dshared-llvm=disabled -Dplatforms=x11,wayland -Dgallium-drivers=swrast,virgl,zink -Dosmesa=true -Dglvnd=true -Dxmlconfig=disabled
    sudo ninja -C build install

After going through either of those routes, you should be able to test with a package like glmark2 using MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform glmark2


One question though, is this the same DRI3 patch from xMeM in question? It looks like it got merged into the termux-packages repo.

iggut commented 7 months ago

@chris-mcdonald-dev

I think I've spent at least a week trying to figure out why this wasn't working properly on a 750 for me 😅

So to summarize (let me know if anything seems off if you don't mind!):

If you have an Adreno 6xx/7xx device

  1. Install a Linux distro with proot in Termux.
  2. Install the latest Termux-X11 app from the GitHub releases page since it supports DRI3.
  3. Download one of the pre-built drivers hansm629 has shared to your proot linux distro (or build it yourself using the commands below)
  4. Inside of your linux distro, install the mesa-vulkan-drivers package you just downloaded (this includes the Turnip driver).

If you have an Andreno 750 device (for now)

This is on an Adreno 750 Snapdragon 8 Gen 3

Just installed proot ubuntu and used the drivers you linked by hansm629 and it sort of works. Here are a few videos of the glitches I get. GLmark + gears vkmark vkmark gets around 2300fps when not screen capturing, for some reason the other benchmarks seem not affected by the recording.

Maybe I have something wrong with my start script if anyone could please take a look:

#!/bin/sh

# Kill open X11 processes
kill -9 $(pgrep -f "termux.x11") 2>/dev/null

# Enable PulseAudio over Network
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.>

# Prepare termux-x11 session
XDG_RUNTIME_DIR=${TMPDIR} termux-x11 :0 -ac -extension MIT-SHM &

# Wait a bit until termux-x11 gets started.
sleep 3

# Launch Termux X11 main activity
am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity > /dev/n>
sleep 1

# Login in PRoot Environment.
proot-distro login ubuntu --user droidmaster --shared-tmp --no-sysvipc ->

exit 0

Thanks to @hansm629 and @Verycuteabbey as I was able to piece together from the comments how to get things running. Any help with the glitching you can see in my videos would be highly appreciated.

hansm629 commented 7 months ago

@iggut

xMeM created a new dri3 patch (Thank you again for your hard work.) I builded turnip by applying it to the branch below.

https://gitlab.freedesktop.org/Danil/mesa/-/tree/review/a750-changes

This branch is the most stable branch that supports Adreno 750.

mesa-vulkan-kgsl_24.1.0-devel-20240324_arm64.deb

After downloading the above deb package Install PRoot-Distro on Linux. (I recommend Debian 12.)

Artifacts occur in OpenGL ES when used with zink. Adding the environment variables below will not cause any artifacts.

MESA_VK_WSI_PRESENT_MODE=mailbox

And for vulkan-loader We recommend using version libvulkan1_1.3.250.0-1_arm64.deb.

The screenshots below are the results of testing on my Galaxy S24 Ultra.

Strangely, mesa 22.3.6 distributed in Debian 12 main-repo seems to be more stable than the latest mesa 24.0.0? 스크린샷_2024-04-09_00-53-33 스크린샷_2024-04-09_00-54-02 스크린샷_2024-04-09_00-55-20 스크린샷_2024-04-09_00-57-24 스크린샷_2024-04-09_00-57-48 스크린샷_2024-04-09_00-59-15

mistune commented 7 months ago

@hansm629 I am looking at building an rpm installer for Fedora 39 in termux. Can you please share to the latest branch you are currently using? If you have the build instructions too that would be great. Thanks.

MastaG commented 7 months ago

@mistune I think most users are building mesa git with a bunch of open merge requests applied on top of it. You can see all current open MR's for turnip by checking the label: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests?label_name%5B%5D=turnip However some MR's will cause glitches/bugs (depending on the GPU), so it requires some testing, especially if you're going to run games with box86/64. Personally I wish airidosas252 would share his sources, the builds on his telegram channel are very popular and well tested: https://t.me/airidosas252builds

iggut commented 7 months ago

@hansm629 Any chance you could please provide your start script to get xfce4 to start with zink like in your screenshots? I'll use it as an example. My brain in in information overload on top of two week old baby lol

TingyiChen commented 6 months ago

@iggut Same here. i saw someone got xfce running with zink accelerated on the same device as mine (Galaxy Tab S9), but stuck at mesa error here. Found one issue about the error but no solution: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9903

hansm629 commented 6 months ago

@iggut @TingyiChen

If you change the vblank_mode value from auto -> off in xfwm4.xml, zink will work well in XFCE4.

MastaG commented 6 months ago

@iggut @TingyiChen

If you change the vblank_mode value from auto -> off in xfwm4.xml, zink will work well in XFCE4.

Yeah this seems to work fine, no more GL4ES! Thx for this. I've built mesa main git with the wsi patch from here: https://github.com/alexvorxx/Zink-Mesa-Xlib/releases (04-wsi-termux-x11-only-kgsl_fixed.patch). I'm not sure if this is the correct DRI3/WSI patch but it seems to run just fine on my S24. So I guess basic Adreno 750 support seems to be in good shape mesa main git, at least for running XFCE4 (with vblank_mode turned off). I haven't tested any games or box64 yet.

Banzayka commented 5 months ago

@hansm629

Hi, apologies in advance for probably off-topic question (just have no idea where to ask, didn't manage to find info) - is there any possibility to build Turnip driver for Adreno 730 natively in Termux - NOT in proot?

hansm629 commented 5 months ago

@Banzayka

hello. Are you talking about mesa turnip dri3 running in Termux native XFCE4 environment?

It is already distributed in Termux main-repo.

pkg install mesa-vulkan-icd-freedreno-dri3

You can install it by entering the above command.

It is based on mesa 24.0.4 and supports Adreno 6xx/7xx series. (However, Adreno 750 is not yet supported.)

MESA_NO_ERROR=1 MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform MESA_GL_VERSION_OVERRIDE=4.6COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 Programname

If you enter the above command or add it as an environment variable, Programs and XFCE4 can be accelerated to OpenGL4.6&OpenGL ES3.2 through zink.

Before running XFCE4 with zink

You must modify vblank_mode to off in xfwm4.xml.

Banzayka commented 5 months ago

@hansm629

Many thanks for your time & efforts, this is greatly appreciated! You literally made my day, this topic is much clearer to me now & I'm super excited to continue exploring ^^

Special thanks for noob-friendly style of answer, very detailed & helpful! :)

JustYou0-0 commented 5 months ago

@hansm629

Sir, I'm really² newbie to this thing,

Can I install your turnip package to my chroot Debian/Ubuntu?

And how to launch xfce4 with hardware acceleration? / What commands to add in my start scripts?

Many² thanks 👍

hansm629 commented 4 months ago

@JustYou0-0

hello. sir Sorry for the late reply.

yes The mesa turnip dri3 (mesa-vulkan-kgsl_24.1.0-devel-20240324_arm64.deb) I build is Available in proot ubuntu and proot debian!

Adreno 650, Adreno 730, Adreno 740, Adreno 750 Confirmed that it works well.

The proot debian linux script I run is as follows:

#!/bin/sh
killall -9 termux-x11 pulseaudio virgl_test_server_android
termux-wake-lock; termux-toast "Starting Debian Liunx"

# Termux-X11 start
am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity
df | grep /storage | cut -d "/" -f 4-
# X11 start
XDG_RUNTIME_DIR=${TMPDIR} termux-x11 :0 -ac -extension MIT-SHM &
sleep 3

# Audio server
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1

# Linux login
touch ~/something
proot-distro login --bind ~/something:/proc/bus/pci/devices debian --user userid --shared-tmp --no-sysvipc -- bash -c "export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1:4713; MESA_NO_ERROR=1 MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform MESA_GL_VERSION_OVERRIDE=4.6COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 dbus-launch --exit-with-session startxfce4"

proot-distro login --bind ~/something:/proc/bus/pci/devices debian --user userid In the script above

For userid, enter the sudo ID you are using.

Before running XFCE4 with zink You must modify vblank_mode to off in xfwm4.xml.

hansm629 commented 4 months ago

@romanovj

hello. sir long time no see.

Thanks to you, I was able to successfully build turnip dri3 for proot Linux! :)

I would like to ask for your help again.

https://github.com/alexvorxx/Zink-Mesa-Xlib/releases/download/v0.0.7beta/04-wsi-termux-x11-only-kgsl_fixed.patch

Via the Termux-x11 dri3 patch above I'm trying to build mesa-vulkan-icd-freedreno for Termux native on the mesa-24.1.1 branch that started supporting Adreno 750, but it keeps failing. (I'm planning to test it on the Galaxy S24 Ultra.)

I am familiar with build deb packages for Linux, but I am not yet familiar with building Termux packages and it seems difficult....

Could you build it as a deb for Termux like before?

MastaG commented 4 months ago

The Debian packaging system is really awful to work with. I wanted to setup a CI repository doing nightly builds of mesa with the turnip kgsl/dri patch for x86, x86-64 (for slipstreaming into Fex rootfs, arm32 and arm64. But the way those debian packages are built seems like you have to provide a lot of manual info in the control files... What a nightmare compared to arch linux pkgbuild or redhat spec files.

hansm629 commented 4 months ago

@MastaG deb running on Proot Debian was successful. The deb running on Termux native XFCE4 keeps failing.

MastaG commented 4 months ago

So I've asked airidosas252 for his latest dri3/dmabuf/kgsl patches, a user named "xiaoyangnoob" replied with a copy of these patches in his personal github repository. See: https://github.com/airidosas252/glibc-wine/issues/4#issuecomment-2192615005

So I've a github runner which takes oibaf's nightly mesa builds and rebuild them with these patches applied and kgsl enabled. https://launchpad.net/~mastag/+archive/ubuntu/mesa-turnip-kgsl Here's the source for the buildscript, action and patches: https://github.com/MastaG/mesa-turnip-ppa/tree/main (I welcome anybody to open up PR's for improvements)

It's currently only for Ubuntu 24.04. I'll soon extend the build script to use Docker to build for 24.10 as well (github actions doesn't have a 24.10 runner yet).

Also mesa git currently fails to build for armhf, so no 32bit driver yet. See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11392 But I've setup Ubuntu 24.04 on my Odroid XU4 to see if I can easily fix this myself.

MastaG commented 4 months ago

So I've fixed armhf (32bit) builds and also added a runner for building the ppa for Ubuntu 24.10. Unfortunately we'll have to wait for obiaf's private key to be migrated to 4096bit before we can check out and build for 24.10. But that shouldn't take long.

hansm629 commented 4 months ago

@MastaG

When build the turnip package

fix-for-anon-file.patch fix-for-getprogname.patch mesa-2934e1f-termux-x11-dri3.patch zink_fixes.patch

Do you apply and build them all?

Or do you build by only applying mesa-2934e1f-termux-x11-dri3.patch?

MastaG commented 4 months ago

@hansm629 I've applied them all. The script loops through all files in the directory and adds them to debian/patches. See the package details (just click on "mesa"): https://launchpad.net/~mastag/+archive/ubuntu/mesa-turnip-kgsl/+packages Feel free to update/submit other patches, then they'll be applied for the next nightly update :)

I've just tried the ppa on my Samsung S24 and it works great.

sudo add-apt-repository ppa:mastag/mesa-turnip-kgsl
sudo apt update
sudo apt -y dist-upgrade

With: MESA_NO_ERROR=1 MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform And: vblank_mode set to off in xfwm4.xml. Schermafdruk_2024-07-02_09-42-26

I've fixed the armhf (32bit) mesa build, so we can use it with box86 as well :)

Now we only need to wait for launchpad to re-sign Oibaf's packages with a new private key so we can build for Ubuntu 24.10 as well.

Thanks to @Weab-chan I've also added a runner for building nightly turnip driver releases for use with emulators such as Yuzu, Strato, Flycast etc Both vanilla and with the patches applied. These are added under the "Releases" section.

hansm629 commented 4 months ago

@MastaG What is the approximate performance of vkmark?

MastaG commented 4 months ago

@hansm629

$ vkmark
ERROR:             VkInstanceCreateInfo::pApplicationInfo::apiVersion has value of 0 which is not permitted. If apiVersion is not 0, then it must be greater than or equal to the value of VK_API_VERSION_1_0 [VUID-VkApplicationInfo-apiVersion]
=======================================================
    vkmark 2017.08
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x43051401
    Device Name:    Turnip Adreno (TM) 750
    Driver Version: 101345449
    Device UUID:    1ee7368ad77036eba2841dac6b30f6aa
=======================================================
[vertex] device-local=true: FPS: 202 FrameTime: 4.950 ms
[vertex] device-local=false: FPS: 189 FrameTime: 5.291 ms
[texture] anisotropy=0: FPS: 186 FrameTime: 5.376 ms
[texture] anisotropy=16: FPS: 188 FrameTime: 5.319 ms
[shading] shading=gouraud: FPS: 186 FrameTime: 5.376 ms
[shading] shading=blinn-phong-inf: FPS: 193 FrameTime: 5.181 ms
[shading] shading=phong: FPS: 201 FrameTime: 4.975 ms
[shading] shading=cel: FPS: 183 FrameTime: 5.464 ms
[effect2d] kernel=edge: FPS: 200 FrameTime: 5.000 ms
[effect2d] kernel=blur: FPS: 182 FrameTime: 5.495 ms
[desktop] <default>: FPS: 188 FrameTime: 5.319 ms
[cube] <default>: FPS: 194 FrameTime: 5.155 ms
[clear] <default>: FPS: 240 FrameTime: 4.167 ms
=======================================================
                                   vkmark Score: 194
=======================================================
hansm629 commented 4 months ago

@MastaG

Considering Adreno 750, the performance seems to be too low.

https://github.com/alexvorxx/Zink-Mesa-Xlib/releases/download/v0.0.7beta/04-wsi-termux-x11-only-kgsl_fixed.patch

After applying the above patch and building turnip in mesa-main As a result of testing on Adreno 740, the performance is as follows.

$ vkmark
=======================================================
    vkmark 2017.08
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x43050A01
    Device Name:    Turnip Adreno (TM) 740
    Driver Version: 100667491
    Device UUID:    0188d9cfb041b3bfcf0ce271ca9e080d
=======================================================
[vertex] device-local=true: FPS: 2211 FrameTime: 0.452 ms
[vertex] device-local=false: FPS: 2190 FrameTime: 0.457 ms
[texture] anisotropy=0: FPS: 2122 FrameTime: 0.471 ms
[texture] anisotropy=16: FPS: 2138 FrameTime: 0.468 ms
[shading] shading=gouraud: FPS: 2126 FrameTime: 0.470 ms
[shading] shading=blinn-phong-inf: FPS: 2120 FrameTime: 0.472 ms
[shading] shading=phong: FPS: 2095 FrameTime: 0.477 ms
[shading] shading=cel: FPS: 2130 FrameTime: 0.469 ms
[effect2d] kernel=edge: FPS: 2464 FrameTime: 0.406 ms
[effect2d] kernel=blur: FPS: 2270 FrameTime: 0.441 ms
[desktop] <default>: FPS: 2278 FrameTime: 0.439 ms
[cube] <default>: FPS: 2446 FrameTime: 0.409 ms
[clear] <default>: FPS: 2313 FrameTime: 0.432 ms
=======================================================
                                   vkmark Score: 2223
=======================================================
MastaG commented 4 months ago

@hansm629

Thank you for the feedback, I'll try that patch for the next nightly build and report back the vlmark results to you :)

MastaG commented 4 months ago

@hansm629 I've applied https://github.com/alexvorxx/Zink-Mesa-Xlib/releases/download/v0.0.7beta/04-wsi-termux-x11-only-kgsl_fixed.patch See the changelog where it states which patches and mesa merge requests are being applied: https://launchpadlibrarian.net/737765943/mesa_24.2~git2407030600.260a5f~oibaf-turnip-kgsl~n_source.changes

I'm getting the same ~200fps in vkmark.

I have my phone connected to usb-c dock with keyboard and mouse and I'm using Termux-x11 on Samsung Dex. I don't know why I'm getting such low fps.

I have the following variables set:

XDG_RUNTIME_DIR=/tmp
EXTERNAL_STORAGE=/sdcard
MESA_LOADER_DRIVER_OVERRIDE=zink
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/freedreno_icd.aarch64.json:/usr/share/vulkan/icd.d/freedreno_icd.armv7l.json
TU_DEBUG=noconform
MESA_NO_ERROR=1

For the record these are all the patches which are being applied on top of mesa main git: https://github.com/MastaG/mesa-turnip-ppa/blob/main/turnip-patches/04-wsi-termux-x11-only-kgsl_fixed.patch https://github.com/MastaG/mesa-turnip-ppa/blob/main/turnip-patches/fix-for-anon-file.patch https://github.com/MastaG/mesa-turnip-ppa/blob/main/turnip-patches/fix-for-getprogname.patch https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29873 https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29871 https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29938

hansm629 commented 4 months ago

@MastaG I tested vkmark on turnip that I build myself.

applied the 04-wsi-termux-x11-only-kgsl_fixed.patch patch to the mesa-main branch.

$ vkmark
=======================================================
    vkmark 2017.08
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x43051401
    Device Name:    Turnip Adreno (TM) 750
    Driver Version: 100667491
    Device UUID:    77a39f4e67f509fab897ccc71c89c9b1
=======================================================
[vertex] device-local=true: FPS: 1856 FrameTime: 0.539 ms
[vertex] device-local=false: FPS: 1895 FrameTime: 0.528 ms
[texture] anisotropy=0: FPS: 1788 FrameTime: 0.559 ms
[texture] anisotropy=16: FPS: 1805 FrameTime: 0.554 ms
[shading] shading=gouraud: FPS: 1811 FrameTime: 0.552 ms
[shading] shading=blinn-phong-inf: FPS: 1830 FrameTime: 0.546 ms
[shading] shading=phong: FPS: 1812 FrameTime: 0.552 ms
[shading] shading=cel: FPS: 1837 FrameTime: 0.544 ms
[effect2d] kernel=edge: FPS: 2010 FrameTime: 0.498 ms
[effect2d] kernel=blur: FPS: 1688 FrameTime: 0.592 ms
[desktop] <default>: FPS: 1952 FrameTime: 0.512 ms
[cube] <default>: FPS: 1975 FrameTime: 0.506 ms
[clear] <default>: FPS: 1391 FrameTime: 0.719 ms
=======================================================
                                   vkmark Score: 1819
=======================================================

I tested it in Dex Modafter connecting it to a 1920x1080 display...

It's higher than the your result, but for some reason It is lower than the result of Galaxy Tab S9 Ultra (Adreno 740).

Adreno 740 is tested in Dex Mod after connecting to a 1920x1080 display. A score of 2200 or higher is obtained.

In my personal opinion, the termux-x11-dri3 patch does not yet properly support Adreno 750.

I downloaded the package your build below and tested it with vkmark.

http://ppa.launchpadcontent.net/mastag/mesa-turnip-kgsl/ubuntu/pool/main/m/mesa/mesa-vulkan-drivers_24.2~git2406300600.682153~oibaf-turnip-kgsl~n_arm64.deb

$ vkmark
=======================================================
    vkmark 2017.08
=======================================================
    Vendor ID:      0x5143
    Device ID:      0x43051401
    Device Name:    Turnip Adreno (TM) 750
    Driver Version: 101345449
    Device UUID:    1ee7368ad77036eba2841dac6b30f6aa
=======================================================
[vertex] device-local=true: FPS: 537 FrameTime: 1.862 ms
[vertex] device-local=false: FPS: 604 FrameTime: 1.656 ms
[texture] anisotropy=0: FPS: 564 FrameTime: 1.773 ms
[texture] anisotropy=16: FPS: 605 FrameTime: 1.653 ms
[shading] shading=gouraud: FPS: 577 FrameTime: 1.733 ms
[shading] shading=blinn-phong-inf: FPS: 539 FrameTime: 1.855 ms
[shading] shading=phong: FPS: 562 FrameTime: 1.779 ms
[shading] shading=cel: FPS: 518 FrameTime: 1.931 ms
[effect2d] kernel=edge: FPS: 671 FrameTime: 1.490 ms
[effect2d] kernel=blur: FPS: 570 FrameTime: 1.754 ms
[desktop] <default>: FPS: 573 FrameTime: 1.745 ms
[cube] <default>: FPS: 712 FrameTime: 1.404 ms
[clear] <default>: FPS: 665 FrameTime: 1.504 ms
=======================================================
                                   vkmark Score: 592
=======================================================

Performance is too low. The mesa-2934e1f-termux-x11-dri3.patch patch seems to have a performance problem.

But even taking that into account, your benchmark results are too low. Are you using the latest version of termux-x11?

If it is not the latest version, update the apk and test again.

MastaG commented 4 months ago

@hansm629 Thanks a lot for testing on both of your devices. My device is also a S24 Ultra.

I've updated the build file to only build with the 04-wsi-termux-x11-only-kgsl_fixed.patch. Nothing else for now :) See: https://github.com/MastaG/mesa-turnip-ppa/blob/main/build_ppa.sh

We'll have to wait for obiaf to build the next version tonight, then ours will trigger as well.

Btw I'm building with both msm and kgsl enabled: -Dfreedreno-kmds=msm,kgsl. Do you also build with both? or only kgsl?

As for termux-x11, I just downloaded a release from here: https://github.com/termux/termux-x11/releases/tag/nightly But it's from 3 or 4 months ago, so I'll update that as well tomorrow and try out the new build from the PPA :)

MastaG commented 4 months ago

@hansm629 Quick update using the latest nightly build of termux-x11 from: https://github.com/termux/termux-x11/releases/tag/nightly

I found out the problem when running vkmark. When my phone is connected to usb-c dock in Dex mode, the phone screen turns off and the cpu and/or gpu are in a lower performance state. This causes the benchmark to produce lower results.

When I start scrolling on a random webpage (using the chrome browser) on my phone screen while the vkmark benchmark is running, the first test will show:

[vertex] device-local=true: FPS: 887 FrameTime: 1.127 ms

It's still not within the 2000+ FPS but it's a lot better :)

So for some reason my S24 decides that Termux and/or Termux-X11 shouldn't be using a lot of cpu/gpu cycles while the phone screen is turned off :(

welisonmiranda commented 3 months ago

@hansm629 Hello, could you please share the deb of your last build for debian sid, Im trying to compile but I couldt apply the patch

MastaG commented 3 months ago

The dmabuf patch has been upstreamed by Danylo.

See my repository for nightly builds: https://github.com/MastaG/mesa-turnip-ppa

I've rebased the dri3.patch on mesa main git. You can grab it from the turnip-patches directory. Or grab the deb package from my PPA: https://launchpad.net/~mastag/+archive/ubuntu/mesa-turnip-kgsl

kde-yyds commented 2 months ago

There's freedreno kgsl dri3 patch in xMeM/termux-packages. It works well on my a730.Screenshot_2024-08-14-16-02-55-339_com.termux.x11.jpg

hansm629 commented 2 months ago

@kde-yyds https://github.com/xMeM/termux-packages/actions/runs/10403066269

Is this the package you mentioned?

I'm curious what the environment variables used by freedreno are.

kde-yyds commented 2 months ago

@kde-yyds https://github.com/xMeM/termux-packages/actions/runs/10403066269

Is this the package you mentioned?

I'm curious what the environment variables used by freedreno are.

yeah. I applied the patches and built mesa in a chroot archlinux container.
MESA_LOADER_DRIVER_OVERRIDE=kgsl