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

mesa: Enable Zink support #10103

Closed
DLC01 opened this issue Mar 16, 2022 · 48 comments · Fixed by #17112
Closed

mesa: Enable Zink support #10103

DLC01 opened this issue Mar 16, 2022 · 48 comments · Fixed by #17112
Labels
enhancement video Issue related to video device support, not X11 necessarily.

Comments

@DLC01
Copy link
Contributor

DLC01 commented Mar 16, 2022

Version 22.0 of mesa was released quite recently, and it includes some fixes which makes it possible to use the Zink(opengl over vulkan) driver in termux to achieve hardware accelerated openGL without root
i had tried to build it in GitHub actions and always ended up with errors saying llvm-config was not found and i faced some Linking issues if i tried to build only the Zink driver, i hope someone can figure out how to fix the build issues and package this

sorry for my bad English...
Screenshot_2022-03-16-14-59-33-370_com termux

as for devices which lacks vulkan support, the swrast llvmpipe driver works without any modifications

the patch which I applied is this:

diff --color -uNr mesa-22.0.0/bin/install_megadrivers.py mesa-22.0.0.mod/bin/install_megadrivers.py
--- mesa-22.0.0/bin/install_megadrivers.py      2022-03-10 02:09:17.000000000 +0530
+++ mesa-22.0.0.mod/bin/install_megadrivers.py  2022-03-10 07:50:41.086537022 +0530
@@ -24,7 +24,16 @@

 import argparse
 import os
+import shutil

+def link(src, dest):
+    shutil.copyfile(src, dest)
+
+def unlink(src):
+    os.remove(src)
+
+os.link = link
+os.unlink = unlink

 def main():
     parser = argparse.ArgumentParser()
diff --color -uNr mesa-22.0.0/src/egl/main/egldisplay.h mesa-22.0.0.mod/src/egl/main/egldisplay.h
--- mesa-22.0.0/src/egl/main/egldisplay.h       2022-03-10 02:09:17.000000000 +0530
+++ mesa-22.0.0.mod/src/egl/main/egldisplay.h   2022-03-10 07:51:02.398537023 +0530
@@ -37,7 +37,7 @@
 #include "egltypedefs.h"
 #include "egldefines.h"
 #include "eglarray.h"
-
+#include <X11/Xlib.h>

 #ifdef __cplusplus
 extern "C" {

and mesa can be built on device with these configuration options

meson -Dplatforms=x11 -Dprefix=$PREFIX -Dcpp_rtti=false -Ddri3=enabled -Ddri-drivers=[] -Dgallium-drivers=swrast,zink -Dvulkan-drivers=[] -Degl=enabled -Dglx=dri -Dshared-glapi=enabled -Dshader-cache=enabled -Dgles1=enabled -Dgles2=enabled -Dllvm=enabled -Dshared-llvm=enabled -Dlmsensors=disabled -Dgbm=disabled -Dlibunwind=disabled -Dopencl-native=false -Dgallium-vdpau=disabled -Dgallium-xvmc=disabled -Dgallium-omx=disabled -Dgallium-va=disabled -Dgallium-xa=disabled -Dmicrosoft-clc=disabled -Dvalgrind=disabled -Dpower8=disabled ..
@thunder-coding thunder-coding transferred this issue from termux/x11-packages Apr 19, 2022
@xtkoba xtkoba added the x11 Issue is related to stuff requiring X11 environment or x11-packages. label Apr 19, 2022
@xtkoba xtkoba changed the title [Help Wanted]: bump mesa to 22.0 mesa: Enable Zink support Apr 24, 2022
@stale
Copy link

stale bot commented Jun 8, 2022

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix Issue won't be fixed. label Jun 8, 2022
@stale stale bot closed this as completed Jun 22, 2022
@Maxython Maxython reopened this Jun 22, 2022
@stale stale bot removed the wontfix Issue won't be fixed. label Jun 22, 2022
@phhusson
Copy link
Contributor

That looks awesome. I'm not sure I understand why it doesn't get more attention, maybe I'm missing something?

I think the second part of your patch is now obsolete thanks to https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18848

If I'm not mistaken, the first one is needed only for building on device itself right? I couldn't manage to get build to even start at all so...

Concerning the meson build parameters, would you know what changes you did? ATM I'm just trying with -Dgallium-drivers=swrast,zink. Are there other changes you did that are required?

@phhusson
Copy link
Contributor

FWIW I managed to get Zink over Android Vulkan to work on termux but that has been very painful.

I'll try to push all I did, and test it on more devices, but in the meantime, a gist of what worked for me:

  • I rebuilt Xwayland with glx (I have a patch locally for building on Termux that I need to send), simply changing disable-glx to enable-glx, I didn't remove the disable-glx patch
  • I switched from EGL to GLX=xlib, using https://github.com/alexvorxx/Zink-Mesa-Xlib, had to tweak it a bit because I had missing VK extensions (I still don't know how you got EGL to work, is it with or without dri2? and why does surfaceless rendering require opening a dri2 screen... So many things I still don't understand)

(and then I used virgl to have GL in proot but that's another story)

@robertkirkman
Copy link

robertkirkman commented Nov 27, 2022

I might have successfully used Zink on Termux on locked bootloader OFW Samsung Galaxy S9 SM-G960U by:

  • Downloading mesa 22.0.5 (the last mesa release that zink is supposed to work on devices whose Android libvulkan.so does not support VK_KHR_xcb_surface and VK_KHR_wayland_surface), patching it with this patch (to get it to build on the LLVM 15 Termux now provides, plus some Termux-specific changes), and compiling it like this:

I had to remove several files belonging to Termux's mesa packages to do this, ninja install told me which ones. I had to do this because unfortunately I was unable to get the mesa source package from this repository to compile on-device due to the same meson LLVM errors OP had, but that didn't happen when compiling manually.

cd mesa
git apply -v mesa.patch
pkg install -y x11-repo
pkg install -y clang lld binutils cmake autoconf automake libtool '*ndk*' make python git libandroid-shmem-static 'vulkan*' ninja llvm bison flex libx11 xorgproto libdrm libpixman libxfixes libjpeg-turbo xtrans libxxf86vm xorg-xrandr xorg-font-util xorg-util-macros libxfont2 libxkbfile libpciaccess xcb-util-renderutil xcb-util-image xcb-util-keysyms xcb-util-wm xorg-xkbcomp xkeyboard-config libxdamage libxinerama
pip install meson mako
mkdir build
cd build
LDFLAGS='-l:libandroid-shmem.a -llog' meson .. -Dplatforms=x11 -Dprefix=$PREFIX -Dcpp_rtti=false -Ddri3=enabled -Ddri-drivers=[] -Dgallium-drivers=swrast,zink -Dvulkan-drivers=[] -Degl=enabled -Dglx=dri -Dshared-glapi=enabled -Dshader-cache=enabled -Dgles1=enabled -Dgles2=enabled -Dllvm=enabled -Dshared-llvm=enabled -Dlmsensors=disabled -Dgbm=disabled -Dlibunwind=disabled -Dopencl-native=false -Dgallium-vdpau=disabled -Dgallium-xvmc=disabled -Dgallium-omx=disabled -Dgallium-va=disabled -Dgallium-xa=disabled -Dmicrosoft-clc=disabled -Dvalgrind=disabled -Dpower8=disabled -Dcpp_rtti=false -Dc_args=-Wno-error=incompatible-function-pointer-types -Dbuildtype=release
rm -rf $PREFIX/lib/libGL*
ninja install
  • Then I downloaded this repository and patched the Termux xwayland source package with this patch, built it on-device following this, and installed the package from the output folder:
cd termux-packages
git apply -v termux-packages.patch
./scripts/setup-termux.sh
./build-package.sh -I -f xwayland
dpkg -i output/xwayland_1.20.5-15_aarch64.deb
  • Finally I compiled and installed normal glmark2 for x11-gl, launched Termux:X11 from an Android GUI app shortcut first (that's the only way I've gotten Termux:X11 to work for me regardless of Zink), and then launched glmark2:
cd glmark2
meson setup build -Dflavors=x11-gl -Dprefix=$PREFIX
ninja -C build
ninja -C build install
DISPLAY=:0 GALLIUM_DRIVER=zink glmark2

I say "might have successfully used Zink" because unfortunately I am not getting great performance. My FPS in glxgears is worse with zink than with llvmpipe, (~150 vs ~200 FPS), and my score in glmark2 seems almost identical between them (~60).

zink

phhusson posted while I wrote this. Soon I might try what he suggested, in the hope of finding a way to improve performance, but it is possible that maybe my OFW Android installation's Vulkan driver is just not good enough for this.

Credit to Thundersnow#7929, RICK#7270 for helping me and writing some parts of the method I described.

@phhusson
Copy link
Contributor

FWIW, In my case, it looks like framerate is limited by the many memcpys, because I can set UT2004 graphic settings to the maximum and still get the same FPS. That's a given since I'm using glx=xlib.
I don't know if that applies to you, since I don't understand how you can get dri to work...

@robertkirkman
Copy link

robertkirkman commented Dec 1, 2022

@phhusson is the problem you have with EGL "error: unknown type name 'Display'"? If so does this help? I believe that problem only affects a certain range of mesa commits.

also, on Termux this has to be reverted, another problem that only affects mesa versions newer than the one I described above.

@robertkirkman
Copy link

robertkirkman commented Dec 1, 2022

Okay, I have Zink from mesa main branch "working" on my device at least as well as the older version of mesa does. The process I'm using is mostly identical to my first message, except with the mesa steps changed to this:

pkg install -y x11-repo
pkg install -y clang lld binutils cmake autoconf automake libtool '*ndk*' make python git libandroid-shmem-static 'vulkan*' ninja llvm bison flex libx11 xorgproto libdrm libpixman libxfixes libjpeg-turbo xtrans libxxf86vm xorg-xrandr xorg-font-util xorg-util-macros libxfont2 libxkbfile libpciaccess xcb-util-renderutil xcb-util-image xcb-util-keysyms xcb-util-wm xorg-xkbcomp xkeyboard-config libxdamage libxinerama libxshmfence
pip install meson mako
git clone https://gitlab.freedesktop.org/mesa/mesa.git
cd mesa
git apply -v mesa-main.patch
mkdir build
cd build
LDFLAGS='-l:libandroid-shmem.a -llog' meson .. -Dplatforms=x11 -Dprefix=/data/data/com.termux/files/usr -Dcpp_rtti=false -Ddri3=enabled -Ddri-drivers=[] -Dgallium-drivers=swrast,zink -Dvulkan-drivers=[] -Degl=enabled -Dglx=dri -Dshared-glapi=enabled -Dshader-cache=enabled -Dgles1=enabled -Dgles2=enabled -Dllvm=enabled -Dshared-llvm=enabled -Dlmsensors=disabled -Dgbm=enabled -Dlibunwind=disabled -Dgallium-vdpau=disabled -Dgallium-omx=disabled -Dgallium-va=disabled -Dgallium-xa=disabled -Dmicrosoft-clc=disabled -Dvalgrind=disabled -Dpower8=disabled -Dcpp_rtti=false -Dc_args=-Wno-error=incompatible-function-pointer-types -Dbuildtype=release
ninja install

where mesa-main.patch is this. It's mostly a collection of things Thundersnow#7929 and RICK#7270 gave me, that removes the requirements for VK_KHR_xcb_surface, VK_KHR_wayland_surface, VK_KHR_imageless_framebuffer and VK_KHR_timeline_semaphore, because my device does not support them. I left the requirement for VK_KHR_create_renderpass2 because I believe my device does support that one, but if you want to remove that too you would revert this commit.

Unfortunately, at least in my case, none of this seems to have changed anything for me, since I get exactly the same performance in glmark2 and glxgears with this build that I did with the older mesa version. The "ZINK: warning, this is cpu-based conditional rendering, say bye-bye to fps" did go away, but that's about it.

@robertkirkman
Copy link

robertkirkman commented Dec 1, 2022

will zink work with proot distro using virgl vtest ?

for zink proot, you additionally need (outside the proot) custom libxshmfence, custom libepoxy, custom virglrenderer, additional mesa changes, and additional environment variables and arguments both inside and outside the proot. You can find the full directions for zink proot scattered throughout various messages in the #x11 channel of the Termux official discord server https://discord.gg/HXpF69X . I have not started trying to use zink in proot yet, but if I ever get enough performance and then I need to use software that absolutely requires glibc, I will enter proot and try it.

@phhusson
Copy link
Contributor

phhusson commented Dec 1, 2022

Actually for proot, if you don't mind destroying performances, you can proot --disable-shm (or whatever it's called), and it'll work without any patch. It'll just do even more memcpys. I have UT2004 demo in wine in box86 (or more simply glxgears or supertux2) in debian proot on unmodified epoxy/virgl/epoxy with that

Thanks @robertkirkman for the detailed up-to-date documentation, I'll give it a try. FWIW I tried reverting the renderpass2 commit (because my Snapdragon 835 doesn't have it) and failed, but I didn't spend much time on it yet.

@phhusson is the problem you have with EGL "error: unknown type name 'Display'"? If so does this help? I believe that problem only affects a certain range of mesa commits.

Nope, issue was something along the lines of "can't open dri screen"

@DLC01
Copy link
Contributor Author

DLC01 commented Dec 1, 2022

Nope, issue was something along the lines of "can't open dri screen"

try compiling Xwayland with

--enable-dri --enable-dri2 --enable-dri3

these were enabled in my build of Xorg

@xDoge26
Copy link

xDoge26 commented Dec 1, 2022

is this really zink or its just cpu rendering
https://www.bilibili.com/read/cv19133555

@robertkirkman
Copy link

FWIW I tried reverting the renderpass2 commit

Here's another patch I made that includes all the changes of the previous patch I posted, plus my attempt to remove the VK_KHR_create_renderpass2 requirement as well: https://clbin.com/IYvs1

@robertkirkman
Copy link

is this really zink or its just cpu rendering https://www.bilibili.com/read/cv19133555

That is the same method we are discussing here, so it should be the same, plus it does have the virgl steps you wanted; how much of the rendering ends up being done by CPU and how much by GPU, seems like it could vary depending on device, since in my case at the moment there's not an observable difference in performance between zink and llvmpipe

@robertkirkman
Copy link

Finally, I have been able to test on some other devices, which do not support VK_KHR_create_renderpass2. So on closer inspection across 30 iterations of glmark2, 5 per configuration and all using current mesa main built with the most recent patch I posted applied, I can confirm the following:

  • There is an observable difference in performance between zink and llvmpipe
  • The first device I was testing (SM-G960U) is just performing really badly with zink for some unknown reason, while other devices perform better
  • The patch does appear to remove the need for VK_KHR_create_renderpass2, at least sufficiently for glmark2, I didn't notice any artifacts
  • Finally I have a device where I can see zink outperform llvmpipe consistently

image

I can move on to testing what I really want. I will also try to see if I can fix or at least work around the termux-packages mesa meson llvm-config problem.

@phhusson
Copy link
Contributor

phhusson commented Dec 2, 2022

WRT performances, I believe that the main issue is that framebuffer is memcpy-ed, so if you were to trying a much more complicated 3D scene, you'd still get the same FPS over zink, but much lower on llvmpipe

@phhusson
Copy link
Contributor

phhusson commented Dec 2, 2022

Testing on FxTec Pro1 (Snapdragon 835, Android 9 vendor/drivers, Android 13 ROM), following your instructions @robertkirkman, using IYvs1, I get null pointer segfault:

#0  0x0000007d16539484 in dri_sw_displaytarget_create () from /data/data/com.termux/files/usr/lib/dri/zink_dri.so
#1  0x0000007d165d0c4c in resource_create () from /data/data/com.termux/files/usr/lib/dri/zink_dri.so
#2  0x0000007d15ef7c74 in kopper_allocate_textures () from /data/data/com.termux/files/usr/lib/dri/zink_dri.so
#3  0x0000007d15ef2414 in dri_st_framebuffer_validate () from /data/data/com.termux/files/usr/lib/dri/zink_dri.so
#4  0x0000007d161e9458 in st_framebuffer_validate () from /data/data/com.termux/files/usr/lib/dri/zink_dri.so

From a quick look it looks related to SHM. I'll spend more time looking at it, but I'm just posting here in case you have an idea/know what's happening

@robertkirkman
Copy link

robertkirkman commented Dec 2, 2022

following your instructions @robertkirkman, using IYvs1, I get null pointer segfault

Thanks for the report, unfortunately for our situation, some parts of zink have been rewritten since the commits that dropped support for these devices' original firmware, so I probably haven't reverted the commits correctly. I might have written undefined behavior that has triggered the crash on your device but not mine (yet). There are a few things you could try:

  • Compile mesa with -Dbuildtype=debug and use gdb to try to identify the line where the crash occurs
  • Try using mesa 22.0.5 which was the last release to officially support our devices' orginal firmware, by following the guide and using the patch in my first post. The patch there is primarily for compiling that mesa release against LLVM 15, and might not give you the same problem.
  • You could try retracing the steps I took to revert the commits, to see if you can figure out a way to do it that might be more correct. If I had to guess, I would say that the commit I've incorrectly reverted is most likely one of these.
  • You mentioned that you are using a custom ROM, forgive me if I'm wrong, but if that means you also have access to root with Magisk, another option becomes available to you in compiling the mesa open source Vulkan driver for your GPU, to replace the vendor one. I haven't tested that yet, but I have seen evidence that doing so can cause the device to suddenly support more Vulkan extensions than it normally would, though the only one I've noticed in that specific example that seems related to zink is VK_EXT_line_rasterization. It's possible for me to try that on SM-T820 which also has Adreno 530 so I could find out what happens, but it would take a while.

@phhusson
Copy link
Contributor

phhusson commented Dec 2, 2022

Thanks for the =debug, =release was right in the command line but i couldn't understand why i didn't get debugging symbols
If all fails I'll try 22.0.5, but I'd hate that, not being able to upgrade is not great.
With regards to Turnip, my device doesn't support turnip as far as I know, though yeah I'm exploring the possibility of using freedreno instead. But really I'd like to have a generic Zink that works on as many devices as possible.

So far, nopper looks like a big nope:
The code you gave does a straight null pointer dereference:

   struct kopper_displaytarget *cdt = NULL;
   cdt->loader_private = NULL;

but then it returns null, but zink explicitly wants non-null assert(res->obj->dt);

So far I have a hard time seeing how it works for you. I'm guessing it goes to a whole different code path, but I don't really see how

@phhusson
Copy link
Contributor

phhusson commented Dec 2, 2022

@robertkirkman WRT the benchmarks result, have you tried running glmark2 with --off-screen?

@phhusson
Copy link
Contributor

phhusson commented Dec 2, 2022

On ROG Phone 3 (Snapdragon 865), which has the zink glx=xlib + virgl + proot setup I mentioned earlier, I get those results on glmark2, 800x600 32bits:
zink + off-screen: 627
zink + on-screen: 87
llmvpipe + off-screen: 157
llmvpipe + on-screen: 107

So yeah in my case, zink definitely works, the bottleneck is the rendering to display which does a lot of buffer copies

@robertkirkman
Copy link

robertkirkman commented Dec 2, 2022

The code you gave does a straight null pointer dereference

Unfortunately, I don't fully understand that code (nopper.c) either, which I copied from someone else. It is intended to remove the requirement for VK_KHR_xcb_surface/VK_KHR_xlib_surface, which I believe was added in these commits. Maybe if those commits were fully reverted too instead of attempting this workaround, then mesa main would work without that crash happening.

As for --off-screen, thanks for the tip, I've run glmark2 again 4 more times on the SM-G960U and SM-G930U, this time with --off-screen, and I got these results:
SM-G930U zink : 119
SM-G930U llvmpipe: 65
SM-G960U zink : 432
SM-G960U llvmpipe: 73

So it does look like the scores increase across the board and shows zink outperforms llvmpipe on SM-G960U. I'll take this into consideration when testing more intensive apps than glmark2, because maybe it means benchmarks can't predict the performance in this scenario.

@xtkoba xtkoba added video Issue related to video device support, not X11 necessarily. and removed x11 Issue is related to stuff requiring X11 environment or x11-packages. labels Jan 19, 2023
@Ma445-cell
Copy link

But when I try to apply the patch it says error: scripts/build/setup/termux_setup_meson.sh: No such file or directory

@twaik
Copy link
Member

twaik commented Jun 8, 2023

I've compared mesa source used in exagear mod and wrote this patch:

+++ ./src/gallium/drivers/zink/zink_resource.c
@@ -45,6 +45,7 @@
 #include "util/u_upload_mgr.h"
 #include "util/os_file.h"
 #include "frontend/winsys_handle.h"
+#include "frontend/sw_winsys.h"
 
 #if !defined(__APPLE__)
 #define ZINK_USE_DMABUF
@@ -1249,6 +1250,17 @@
       res->aspect = aspect_from_format(templ->format);
    }
 
+   if (screen->winsys && (templ->bind & PIPE_BIND_DISPLAY_TARGET)) {
+      struct sw_winsys *winsys = screen->winsys;
+      res->dt = winsys->displaytarget_create(screen->winsys,
+                                             res->base.b.bind,
+                                             res->base.b.format,
+                                             templ->width0,
+                                             templ->height0,
+                                             64, NULL,
+                                             &res->dt_stride);
+   }
+
    if (loader_private) {
       if (templ->bind & PIPE_BIND_DISPLAY_TARGET) {
          /* backbuffer */
+++ ./src/gallium/drivers/zink/zink_screen.c
@@ -49,6 +49,7 @@
 #include "util/xmlconfig.h"
 
 #include "util/u_cpu_detect.h"
+#include "frontend/sw_winsys.h"
 
 static int num_screens = 0;
 bool zink_tracing = false;
@@ -1612,6 +1613,7 @@
 {
    struct zink_screen *screen = zink_screen(pscreen);
    struct zink_resource *res = zink_resource(pres);
+#if 0
    struct zink_context *ctx = zink_context(pctx);
 
    /* if the surface is no longer a swapchain, this is a no-op */
@@ -1643,6 +1645,31 @@
    /* always verify that this was acquired */
    assert(zink_kopper_acquired(res->obj->dt, res->obj->dt_idx));
    zink_kopper_present_queue(screen, res);
+#endif
+
+   struct sw_winsys *winsys = screen->winsys;
+
+   if (!winsys)
+     return;
+   void *map = winsys->displaytarget_map(winsys, res->dt, 0);
+
+   if (map) {
+      struct pipe_transfer *transfer = NULL;
+
+      void *res_map = pipe_texture_map(pctx, pres, level, layer, PIPE_MAP_READ, 0, 0,
+                                        u_minify(pres->width0, level),
+                                        u_minify(pres->height0, level),
+                                        &transfer);
+      if (res_map) {
+         util_copy_rect((ubyte*)map, pres->format, res->dt_stride, 0, 0,
+                        transfer->box.width, transfer->box.height,
+                        (const ubyte*)res_map, transfer->stride, 0, 0);
+         pipe_texture_unmap(pctx, transfer);
+      }
+      winsys->displaytarget_unmap(winsys, res->dt);
+   }
+
+   winsys->displaytarget_display(winsys, res->dt, winsys_drawable_handle, sub_box);
 }
 
 bool
@@ -3091,6 +3118,7 @@
 {
    struct zink_screen *ret = zink_internal_create_screen(config);
    if (ret) {
+      ret->winsys = winsys;
       ret->drm_fd = -1;
    }
 
+++ ./src/gallium/drivers/zink/zink_types.h
@@ -1275,6 +1275,7 @@
    bool swapchain;
    bool dmabuf;
    unsigned dt_stride;
+   struct sw_displaytarget *dt;
 
    uint8_t modifiers_count;
    uint64_t *modifiers;
@@ -1354,6 +1355,7 @@
    uint64_t db_size[ZINK_DESCRIPTOR_ALL_TYPES];
    unsigned base_descriptor_size;
    VkDescriptorSetLayout bindless_layout;
+   struct sw_winsys *winsys;
 
    struct {
       struct pb_cache bo_cache;

Unfortunately gl programs with GALLIUM_DRIVER=zink fall with this error

../src/src/util/xmlconfig.c:1276: unsigned char driQueryOptionb(const driOptionCache *, const char *): assertion "cache->info[i].name != NULL" failed
Aborted

@twaik
Copy link
Member

twaik commented Jun 8, 2023

@licy183 maybe you can help?

@twaik
Copy link
Member

twaik commented Jun 9, 2023

Ok, this seems to fix assert in driQueryOptionb, but there is some other fault.


+++ src2/src/gallium/drivers/zink/zink_screen.c	2023-06-09 02:44:23.468963015 +0300
@@ -2744,11 +2744,11 @@
    if (config) {
       driParseConfigFiles(config->options, config->options_info, 0, "zink",
                           NULL, NULL, NULL, 0, NULL, 0);
-      screen->driconf.dual_color_blend_by_location = driQueryOptionb(config->options, "dual_color_blend_by_location");
-      screen->driconf.glsl_correct_derivatives_after_discard = driQueryOptionb(config->options, "glsl_correct_derivatives_after_discard");
+      screen->driconf.dual_color_blend_by_location = 0;
+      screen->driconf.glsl_correct_derivatives_after_discard = 0;
       //screen->driconf.inline_uniforms = driQueryOptionb(config->options, "radeonsi_inline_uniforms");
-      screen->driconf.emulate_point_smooth = driQueryOptionb(config->options, "zink_emulate_point_smooth");
-      screen->instance_info.disable_xcb_surface = driQueryOptionb(config->options, "disable_xcb_surface");
+      screen->driconf.emulate_point_smooth = 0;
+      screen->instance_info.disable_xcb_surface = 0;
    }
 
    if (!zink_create_instance(screen))

Now zink falls with SIGBUS/BUS_ADRALN.

@licy183
Copy link
Member

licy183 commented Jun 10, 2023

@licy183 maybe you can help?

Sorry for my late reply. I have many exams these days. You can compile mesa with -Dxmlconfig=disabled.

@lateautumn233
Copy link

Ok, this seems to fix assert in driQueryOptionb, but there is some other fault.


+++ src2/src/gallium/drivers/zink/zink_screen.c	2023-06-09 02:44:23.468963015 +0300
@@ -2744,11 +2744,11 @@
    if (config) {
       driParseConfigFiles(config->options, config->options_info, 0, "zink",
                           NULL, NULL, NULL, 0, NULL, 0);
-      screen->driconf.dual_color_blend_by_location = driQueryOptionb(config->options, "dual_color_blend_by_location");
-      screen->driconf.glsl_correct_derivatives_after_discard = driQueryOptionb(config->options, "glsl_correct_derivatives_after_discard");
+      screen->driconf.dual_color_blend_by_location = 0;
+      screen->driconf.glsl_correct_derivatives_after_discard = 0;
       //screen->driconf.inline_uniforms = driQueryOptionb(config->options, "radeonsi_inline_uniforms");
-      screen->driconf.emulate_point_smooth = driQueryOptionb(config->options, "zink_emulate_point_smooth");
-      screen->instance_info.disable_xcb_surface = driQueryOptionb(config->options, "disable_xcb_surface");
+      screen->driconf.emulate_point_smooth = 0;
+      screen->instance_info.disable_xcb_surface = 0;
    }
 
    if (!zink_create_instance(screen))

Now zink falls with SIGBUS/BUS_ADRALN.

He can't work normally. Do you have any ideas?

Details

Screenshot_2023-06-12-19-21-36-741_com sonelli juicessh

Details

Cache_4e93e248e16924d3

@twaik
Copy link
Member

twaik commented Jun 12, 2023

I have a new patch.
mesa.tar.gz

@lateautumn233
Copy link

I have a new patch. mesa.tar.gz

No changes

patch -p1 < mesa.patch
meson . build -Dgallium-va=disabled -Dgallium-drivers=virgl,zink,swrast -Ddri3=disabled -Dvulkan-drivers= -Dglx=xlib -Dplatforms=x11 -Dbuildtype=release -Dxmlconfig=disabled && sudo ninja -C build && ninja install -C build

Details

Screenshot_2023-06-12-20-03-41-548_com sonelli juicessh

@twaik
Copy link
Member

twaik commented Jun 12, 2023

Why are you using Zink-Mesa-Xlib repo? It already has these patches...

@lateautumn233
Copy link

Why are you using Zink-Mesa-Xlib repo? It already has these patches...

Sorry, I don't know
I want to use Turnip+Zink on the xfce desktop

@xDoge26
Copy link

xDoge26 commented Jun 12, 2023

Quite off topic but can someone setup github action that build deb file of turnip driver ? I have successfully built turnip driver for proot ubuntu, but i dont know how to make deb file from it

This is how i compile the driver :

sudo dpkg --add-architecture armhf
sudo apt update
sudo apt upgrade
sudo apt build-dep mesa 
apt install make cmake git wget vulkan-tools mesa-utils g++-arm-linux-gnueabihf g++-aarch64-linux-gnu
apt install libgl1:armhf libvulkan1:armhf libglvnd-dev:armhf zlib1g-dev:armhf libexpat1-dev:armhf libdrm-dev:armhf libx11-dev:armhf libxext-dev:armhf libxdamage-dev:armhf libxcb-glx0-dev:armhf libx11-xcb-dev:armhf libxcb-dri2-0-dev:armhf libxcb-dri3-dev:armhf libxcb-present-dev:armhf libxshmfence-dev:armhf libxxf86vm-dev:armhf libxrandr-dev:armhf libwayland-dev:armhf wayland-protocols:armhf libwayland-egl-backend-dev:armhf libxcb-shm0-dev:armhf pkg-config:armhf
apt install libgl1:arm64 libvulkan1:arm64 libglvnd-dev:arm64 zlib1g-dev:arm64 libexpat1-dev:arm64 libdrm-dev:arm64 libx11-dev:arm64 libxext-dev:arm64 libxdamage-dev:arm64 libxcb-glx0-dev:arm64 libx11-xcb-dev:arm64 libxcb-dri2-0-dev:arm64 libxcb-dri3-dev:arm64 libxcb-present-dev:arm64 libxshmfence-dev:arm64 libxxf86vm-dev:arm64 libxrandr-dev:arm64 libwayland-dev:arm64 wayland-protocols:arm64 libwayland-egl-backend-dev:arm64 libxcb-shm0-dev:arm64 pkg-config:arm64

-----------------------------------------------------------------------------------------------------------------------------------------------------------

cp /usr/include/libdrm/drm.h /usr/include/libdrm/drm_mode.h /usr/include/

wget https://gitlab.freedesktop.org/Danil/mesa/-/archive/freedreno/feature/a610/mesa-freedreno-feature-a610.tar.gz
tar -xf ./*.tar.gz
cd mesa-freedreno-feature-a610


meson build64 --libdir=lib/aarch64-linux-gnu -D platforms=x11,wayland -D gallium-drivers=swrast,virgl,zink,freedreno -D vulkan-drivers=freedreno -D dri3=enabled -D egl=enabled -D gles2=enabled -D glvnd=true -D glx=dri -D libunwind=disabled -D osmesa=true -D shared-glapi=enabled -D microsoft-clc=disabled -D valgrind=disabled --prefix /usr -D gles1=disabled -D freedreno-kmds=kgsl -Dbuildtype=release
ninja -C build64/

meson build32 --cross-file=cross.txt --libdir=lib/arm-linux-gnueabihf -D platforms=x11,wayland -D gallium-drivers=swrast,virgl,zink,freedreno -D vulkan-drivers=freedreno -D dri3=enabled -D egl=enabled -D gles2=enabled -D glvnd=true -D glx=dri -D libunwind=disabled -D osmesa=true -D shared-glapi=enabled -D microsoft-clc=disabled -D valgrind=disabled --prefix /usr -D gles1=disabled -D freedreno-kmds=kgsl -Dbuildtype=release
ninja -C build32/

# warning !! donot run ninja -C build install !!
# instead just copy over turnip driver

cp $(pwd)/build64/src/freedreno/vulkan/libvulkan_freedreno.so /usr/lib/aarch64-linux-gnu/
cp $(pwd)/build32/src/freedreno/vulkan/libvulkan_freedreno.so /usr/lib/arm-linux-gnueabihf/

cp $(pwd)/build64/src/freedreno/vulkan/freedreno_icd.aarch64.json ~/
cp $(pwd)/build32/src/freedreno/vulkan/freedreno_icd.armhf.json ~/

# test turnip 
DISPLAY=:0 TU_DEBUG=noconform MESA_VK_WSI_DEBUG=sw VK_ICD_FILENAMES=~/freedreno_icd.aarch64.json vkcube 

# test zink 
DISPLAY=:0 MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform MESA_VK_WSI_DEBUG=sw VK_ICD_FILENAMES=~/freedreno_icd.aarch64.json glxgears

-----------------------------------------------------------------------------------------------------------------------------------------------------------

nano $(pwd)/cross.txt

[binaries]
c = 'arm-linux-gnueabihf-gcc'
cpp = 'arm-linux-gnueabihf-g++'
ar = 'arm-linux-gnueabihf-ar'
strip = 'arm-linux-gnueabihf-strip'
pkgconfig = 'arm-linux-gnueabihf-pkg-config'

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armhf'
endian = 'little'
-----------------------------------------------------------------------------------------------------------------------------------------------------------

@lateautumn233
Copy link

Quite off topic but can someone setup github action that build deb file of turnip driver ? I have successfully built turnip driver for proot ubuntu, but i dont know how to make deb file from it

This is how i compile the driver :

After I compile it
branch turnip/feature/a7xx-basic-support

DISPLAY=:1 TU_DEBUG=noconform MESA_VK_WSI_DEBUG=sw VK_ICD_FILENAMES=~/freedreno_icd.aarch64.json glxgears
MESA: error: ZINK: vkEnumeratePhysicalDevices failed (VK_ERROR_INITIALIZATION_FAILED)
MESA: error: ZINK: failed to choose pdev
MESA: error: ZINK: vkEnumeratePhysicalDevices failed (VK_ERROR_INITIALIZATION_FAILED)
MESA: error: ZINK: failed to choose pdev
MESA: error: ZINK: vkEnumeratePhysicalDevices failed (VK_ERROR_INITIALIZATION_FAILED)
MESA: error: ZINK: failed to choose pdev
Error: couldn't get an RGB, Double-buffered visual

@xDoge26
Copy link

xDoge26 commented Jun 12, 2023

@lateautumn233 i think you are missing MESA_LOADER_DRIVER_OVERRIDE=zink

@lateautumn233
Copy link

@lateautumn233 i think you are missing MESA_LOADER_DRIVER_OVERRIDE=zink

Nothing happened

Details

Screenshot_2023-06-12-21-56-23-770_com sonelli juicessh

@xDoge26
Copy link

xDoge26 commented Jun 12, 2023

@lateautumn233 Maybe driver for a7xx isnt ready ? It works fine with adreno 610

image
image

@Heasterian
Copy link

@lateautumn233 run some pure vulkan test first, without zink. More layers you add, more potentials points of failure you have and that's bad when you try to troubleshoot anything.

@lateautumn233
Copy link

@lateautumn233 run some pure vulkan test first, without zink. More layers you add, more potentials points of failure you have and that's bad when you try to troubleshoot anything.

I'm trying

DISPLAY=:1 TU_DEBUG=noconform MESA_VK_WSI_DEBUG=sw VK_ICD_FILENAMES=~/freedreno_icd.aarch64.json vkcube

output

vkcube: ./cube/cube.c:3444: demo_init_vk: Assertion `!err' failed.
Aborted

@lateautumn233
Copy link

@lateautumn233 Maybe driver for a7xx isnt ready ? It works fine with adreno 610

Maybe

@500InternalError
Copy link

@lateautumn233 I compiled turnip/feature/a7xx-basic-support and vkcube works just fine with it on SD 8gen1
output.tar.gz

@lateautumn233
Copy link

@lateautumn233 I compiled turnip/feature/a7xx-basic-support and vkcube works just fine with it on SD 8gen1 output.tar.gz

But I'm using chroot

@500InternalError
Copy link

@lateautumn233 I compiled turnip/feature/a7xx-basic-support and vkcube works just fine with it on SD 8gen1 output.tar.gz

But I'm using chroot

This is the patch I'm using, basically https://github.com/termux-user-repository/tur/tur/mesa-zink with some modification.
mesa-zink.zip

@kde-yyds
Copy link

@lateautumn233 I compiled turnip/feature/a7xx-basic-support and vkcube works just fine with it on SD 8gen1 output.tar.gz

But I'm using chroot

i'm also using chroot, vkcube works on turnip adreno 730
but zink doesn't work

alexvorxx added a commit to alexvorxx/zink-xlib-termux that referenced this issue Nov 17, 2023
Revert "zink: require extensions, delete the code"
(https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904/diffs)
- removes the requirements for VK_KHR_xcb_surface,
VK_KHR_wayland_surface, VK_KHR_imageless_framebuffer and
VK_KHR_timeline_semaphore.
This is necessary for Zink to work with the Vulkan driver built into
Android
(termux/termux-packages#10103 (comment)).
alexvorxx added a commit to alexvorxx/zink-xlib-termux that referenced this issue Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement video Issue related to video device support, not X11 necessarily.
Projects
None yet
Development

Successfully merging a pull request may close this issue.