xc-racer99 / mesa-pvr

Mesa fork with PVR patches from the Chromium overlays git at https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/master/media-libs/arc-mesa-img/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eglinfo: eglInitialize failed

sicelo opened this issue · comments

Hi

I have tried this out on SGX540 in the Motorola Droid 4, running postmarketOS. It runs fine, and I can use sway, wlroots, as well as phosh.

However, I am noticing what I think is unexpected behavior. kmscube works fine and detects the availability of EGL, yet eglinfo fails to run. The log is at
https://paste.debian.net/1194751/

I am suspecting this is a small issue to fix, but I have not yet found a solution. Thanks for your help, and for the project!

Weird. Does /usr/lib/xorg/modules/dri/pvr_dri.so exist? Your first error message says it doesn't exist, but I'm pretty sure that it should. It almost sounds like a permissions or environmental variable issue.

I've never tried to run eglinfo though :)

I'm also rather surprised at the frame rate that you're running for kmscube. Is this normal for an OMAP4 device? I get a rock-solid 60fps (the native refresh rate of my display) on an S5PV210 device.

Weird. Does /usr/lib/xorg/modules/dri/pvr_dri.so exist? Your first error message says it doesn't exist, but I'm pretty sure that it should. It almost sounds like a permissions or environmental variable issue.

Correct. It does not exist. Maybe it is the postmarketOS packaging? The pvr_dri.so file also does not exist for @MightyM17 on postmarketOS.

I've never tried to run eglinfo though :)

eglinfo was just an example, which I thought to try because we are failing to start Qt EGLFS applications from the console. They spit out the same error.

I'm also rather surprised at the frame rate that you're running for kmscube. Is this normal for an OMAP4 device? I get a rock-solid 60fps (the native refresh rate of my display) on an S5PV210 device.

I actually get 82fps on the Droid 4. I don't remember why it was low at this point, but that was temporary :)

Weird. Does /usr/lib/xorg/modules/dri/pvr_dri.so exist? Your first error message says it doesn't exist, but I'm pretty sure that it should. It almost sounds like a permissions or environmental variable issue.

Nope, pvr_dri.so doesnt exist in postmarketos. In the APKBUILD itself (https://gitlab.com/postmarketOS/pmaports/-/blob/master/main/mesa-pvr-dri-classic/APKBUILD#L98-108) only omapdrm_dri,exynos_dri,tilcdc_dri,tidss_dri,swrast exists. Thus some uis like Nemo/Glacier, Lomiri just fail to run :(

I'm also rather surprised at the frame rate that you're running for kmscube. Is this normal for an OMAP4 device? I get a rock-solid 60fps (the native refresh rate of my display) on an S5PV210 device.

Yeah even i get consistent 90fps, but it might change on different DE's like in weston its 90fps but in some other it drops to as low as 20fps

Ah, right, I remember now, I changed things to the actual DRM device name so that it could be loaded with the main Mesa package, weird that it's trying to load for the PVR name now... I wonder if something has changed in upstream Mesa that is now causing issues. I'll try and updating my device and test with some things (basically going to test reverting 0e47aea or adding the pvr entrypoint back in plus the custom dri named ones).

Oh, is it not fine to have both of them just for compatibility?

Oh, is it not fine to have both of them just for compatibility?

It should be just fine. The other thing might be that the pvr DRM kernel driver probed first before the omapdrm one, so some programs aren't coded properly and are trying to use it as the output device instead of the omapdrm one.

Right, that might be a very possible cause of the problem

I think we can be fairly certain that omapdrm probes first, according to dmesg

Haven't had a chance to test yet, but attached is a version that I think should fix the issue. Feel free to test it and let me know.
mesa-pvr-dri-classic-20.3.2_p20210425214122-r1.apk.zip

Diff:

diff --git a/meson.build b/meson.build
index 4bfcb05b50c..38678de18bd 100644
--- a/meson.build
+++ b/meson.build
@@ -162,7 +162,7 @@ if dri_drivers.contains('auto')
     if ['x86', 'x86_64'].contains(host_machine.cpu_family())
       dri_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau']
     elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
-      dri_drivers = ['tidss', 'tilcdc', 'omapdrm', 'exynos']
+      dri_drivers = ['tidss', 'tilcdc', 'omapdrm', 'exynos', 'pvr']
     elif ['mips', 'mips64'].contains(host_machine.cpu_family())
       dri_drivers = ['r100', 'r200', 'nouveau']
     else
@@ -188,6 +188,7 @@ with_dri_tilcdc = dri_drivers.contains('tilcdc')
 with_dri_omapdrm = dri_drivers.contains('omapdrm')
 with_dri_exynos = dri_drivers.contains('exynos')
 with_dri_tidss = dri_drivers.contains('tidss')
+with_dri_pvr = dri_drivers.contains('pvr')
 
 with_dri = dri_drivers.length() != 0
 
diff --git a/meson_options.txt b/meson_options.txt
index 4bf772d986b..da0f66f15d1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -45,7 +45,7 @@ option(
   'dri-drivers',
   type : 'array',
   value : ['auto'],
-  choices : ['auto', 'i915', 'i965', 'r100', 'r200', 'nouveau', 'swrast', 'tilcdc', 'tidss', 'omapdrm', 'exynos'],
+  choices : ['auto', 'i915', 'i965', 'r100', 'r200', 'nouveau', 'swrast', 'tilcdc', 'tidss', 'omapdrm', 'exynos', 'pvr'],
   description : 'List of dri drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
 )
 option(
diff --git a/src/mesa/drivers/dri/meson.build b/src/mesa/drivers/dri/meson.build
index f0df9ea3eb4..3cb5a4c5d97 100644
--- a/src/mesa/drivers/dri/meson.build
+++ b/src/mesa/drivers/dri/meson.build
@@ -53,7 +53,7 @@ if with_dri_nouveau
   _dri_link += 'nouveau_vieux_dri.so'
 endif
 
-if (with_dri_tilcdc or with_dri_tidss or with_dri_omapdrm or with_dri_exynos)
+if (with_dri_tilcdc or with_dri_tidss or with_dri_omapdrm or with_dri_exynos or with_dri_pvr)
   subdir('pvr')
   _dri_drivers += libpvr
 endif
@@ -70,6 +70,9 @@ endif
 if with_dri_exynos
   _dri_link += 'exynos_dri.so'
 endif
+if with_dri_exynos
+  _dri_link += 'pvr_dri.so'
+endif
 
 if _dri_drivers != []
   libmesa_dri_drivers = shared_library(
diff --git a/src/mesa/drivers/dri/pvr/pvrdri.c b/src/mesa/drivers/dri/pvr/pvrdri.c
index 273db45cec1..ed98e64f4a8 100644
--- a/src/mesa/drivers/dri/pvr/pvrdri.c
+++ b/src/mesa/drivers/dri/pvr/pvrdri.c
@@ -997,6 +997,14 @@ static const __DRIextension *pvr_driver_extensions[] = {
     NULL
 };
 
+const __DRIextension **__driDriverGetExtensions_pvr(void);
+PUBLIC const __DRIextension **__driDriverGetExtensions_pvr(void)
+{
+   globalDriverAPI = &pvr_driver_api;
+
+   return pvr_driver_extensions;
+}
+
 const __DRIextension **__driDriverGetExtensions_tilcdc(void);
 PUBLIC const __DRIextension **__driDriverGetExtensions_tilcdc(void)
 {
diff --git a/main/mesa-pvr-dri-classic/APKBUILD b/main/mesa-pvr-dri-classic/APKBUILD
index 9661b3e4..5f0b8701 100644
--- a/main/mesa-pvr-dri-classic/APKBUILD
+++ b/main/mesa-pvr-dri-classic/APKBUILD
@@ -56,7 +56,7 @@ options="!check" # we skip tests intentionally
 builddir="$srcdir/mesa-pvr-$_tag"
 
 _dri_driverdir=/usr/lib/xorg/modules/dri
-_dri_drivers="exynos,tidss,tilcdc,omapdrm"
+_dri_drivers="exynos,tidss,tilcdc,omapdrm,pvr"
 
 build() {
 	export CFLAGS="$CFLAGS -D_XOPEN_SOURCE=700"
@@ -103,6 +103,8 @@ package() {
 		"$pkgdir/$_dri_driverdir"/tilcdc_dri.so
 	install -Dm644 output/src/mesa/drivers/dri/libmesa_dri_drivers.so \
 		"$pkgdir/$_dri_driverdir"/tidss_dri.so
+	install -Dm644 output/src/mesa/drivers/dri/libmesa_dri_drivers.so \
+		"$pkgdir/$_dri_driverdir"/pvr_dri.so
 
 	install -Dm644 output/src/gallium/targets/dri/libgallium_dri.so \
 		"$pkgdir/$_dri_driverdir"/swrast.so

Thank you very much for looking into this. I tried the apk provided, and now the pvr_dri.so error is gone. However, EGL still not working in the "GBM platform" section:

droid4:~$ XDG_RUNTIME_DIR=/run/user/10000/ eglinfo
EGL client extensions string:
    EGL_EXT_client_extensions EGL_EXT_device_base
    EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_platform_base
    EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug
    EGL_EXT_platform_device EGL_EXT_platform_wayland
    EGL_KHR_platform_wayland EGL_EXT_platform_x11 EGL_KHR_platform_x11
    EGL_MESA_platform_xcb EGL_MESA_platform_gbm EGL_KHR_platform_gbm
    EGL_MESA_platform_surfaceless

GBM platform:
MESA-LOADER: failed to open kms_swrast: Error loading shared library /usr/lib/xorg/modules/dri/kms_swrast_dri.so: No such file or directory (search paths /usr/lib/xorg/modules/dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: Error loading shared library /usr/lib/xorg/modules/dri/swrast_dri.so: No such file or directory (search paths /usr/lib/xorg/modules/dri)
failed to load swrast driver
MESA-LOADER: failed to open kms_swrast: Error loading shared library /usr/lib/xorg/modules/dri/kms_swrast_dri.so: No such file or directory (search paths /usr/lib/xorg/modules/dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: Error loading shared library /usr/lib/xorg/modules/dri/swrast_dri.so: No such file or directory (search paths /usr/lib/xorg/modules/dri)
failed to load swrast driver
eglinfo: eglInitialize failed

Wayland platform:
eglinfo: eglInitialize failed

X11 platform:
eglinfo: eglInitialize failed

Device platform:
eglinfo: eglInitialize failed

droid4:~$ kmscube
Using display 0xb6e480a0 with EGL version 1.4
===================================
EGL information:
  version: "1.4"
  vendor: "Mesa Project"
  client extensions: "EGL_EXT_client_extensions EGL_EXT_device_base EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug EGL_EXT_platform_device EGL_EXT_platform_wayland EGL_KHR_platform_wayland EGL_EXT_platform_x11 EGL_KHR_platform_x11 EGL_MESA_platform_xcb EGL_MESA_platform_gbm EGL_KHR_platform_gbm EGL_MESA_platform_surfaceless"
  display extensions: "EGL_EXT_buffer_age EGL_EXT_create_context_robustness EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_IMG_context_priority EGL_KHR_config_attribs EGL_KHR_create_context EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_no_config_context EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_EXT_pixel_format_float EGL_KHR_wait_sync EGL_MESA_configless_context EGL_MESA_drm_image EGL_WL_bind_wayland_display "
===================================
OpenGL ES 2.x information:
  version: "OpenGL ES 2.0 build 1.17@4948957"
  shading language version: "OpenGL ES GLSL ES 1.00 build 1.17@4948957"
  vendor: "Imagination Technologies"
  renderer: "PowerVR SGX 540"
  extensions: "GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24 GL_OES_depth_texture GL_OES_egl_sync GL_OES_element_index_uint GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_get_program_binary GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_required_internalformat GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_surfaceless_context GL_OES_texture_float GL_OES_texture_half_float GL_OES_vertex_array_object GL_OES_vertex_half_float GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_EXT_multi_draw_arrays GL_EXT_multisampled_render_to_texture GL_EXT_shader_texture_lod GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_IMG_multisampled_render_to_texture GL_IMG_program_binary GL_IMG_read_format GL_IMG_shader_binary GL_IMG_texture_compression_pvrtc GL_IMG_texture_format_BGRA8888 GL_IMG_texture_npot GL_IMG_uniform_buffer_object GL_KHR_debug GL_EXT_texture_storage"
===================================
Using modifier ffffffffffffff
Modifiers failed!
Using modifier ffffffffffffff
Modifiers failed!
Rendered 162 frames in 2.010686 sec (80.569508 fps)
Rendered 327 frames in 4.017375 sec (81.396441 fps)
Rendered 493 frames in 6.021530 sec (81.872878 fps)
Rendered 658 frames in 8.025869 sec (81.984895 fps)
Rendered 825 frames in 10.031703 sec (82.239280 fps)
^C

Should we also be (re)building libgbm perhaps? At least TI seems to patch libgbm for their blobs (https://elinux.org/BeagleBoneBlack/SGX_%2B_Qt_EGLFS_%2B_Weston#The_GBM_Library )?

So, I copied the existing swrast.so to kms_swrast_dri.so and swrast_dri.so, and now it seems to work :)

droid4:/usr/lib/xorg/modules/dri# eglinfo
EGL client extensions string:
    EGL_EXT_client_extensions EGL_EXT_device_base
    EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_platform_base
    EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug
    EGL_EXT_platform_device EGL_EXT_platform_wayland
    EGL_KHR_platform_wayland EGL_EXT_platform_x11 EGL_KHR_platform_x11
    EGL_MESA_platform_xcb EGL_MESA_platform_gbm EGL_KHR_platform_gbm
    EGL_MESA_platform_surfaceless

GBM platform:
EGL API version: 1.4
EGL vendor string: Mesa Project
EGL version string: 1.4
EGL client APIs: OpenGL OpenGL_ES 
EGL extensions string:
    EGL_ANDROID_blob_cache EGL_EXT_buffer_age EGL_KHR_cl_event2
    EGL_KHR_config_attribs EGL_KHR_create_context
    EGL_KHR_create_context_no_error EGL_KHR_fence_sync
    EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace
    EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image
    EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image
    EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap
    EGL_KHR_no_config_context EGL_KHR_reusable_sync
    EGL_KHR_surfaceless_context EGL_EXT_pixel_format_float
    EGL_KHR_wait_sync EGL_MESA_configless_context
    EGL_MESA_image_dma_buf_export EGL_MESA_query_driver
Configurations:
     bf lv colorbuffer dp st  ms    vis   cav bi  renderable  supported
  id sz  l  r  g  b  a th cl ns b    id   eat nd gl es es2 vg surfaces 
---------------------------------------------------------------------
0x01 32  0  8  8  8  8  0  0  0 0 0x34325241--         y  y  y     win
0x02 32  0  8  8  8  8 16  0  0 0 0x34325241--         y  y  y     win
0x03 32  0  8  8  8  8 24  0  0 0 0x34325241--         y  y  y     win
0x04 32  0  8  8  8  8 24  8  0 0 0x34325241--         y  y  y     win
0x05 32  0  8  8  8  8 32  0  0 0 0x34325241--         y  y  y     win
0x06 32  0  8  8  8  8  0  0  4 1 0x34325241--         y  y  y     win
0x07 32  0  8  8  8  8 16  0  4 1 0x34325241--         y  y  y     win
0x08 32  0  8  8  8  8 24  0  4 1 0x34325241--         y  y  y     win
0x09 32  0  8  8  8  8 24  8  4 1 0x34325241--         y  y  y     win
0x0a 32  0  8  8  8  8 32  0  4 1 0x34325241--         y  y  y     win
0x0b 24  0  8  8  8  0  0  0  0 0 0x34325258--         y  y  y     win
0x0c 24  0  8  8  8  0 16  0  0 0 0x34325258--         y  y  y     win
0x0d 24  0  8  8  8  0 24  0  0 0 0x34325258--         y  y  y     win
0x0e 24  0  8  8  8  0 24  8  0 0 0x34325258--         y  y  y     win
0x0f 24  0  8  8  8  0 32  0  0 0 0x34325258--         y  y  y     win
0x10 24  0  8  8  8  0  0  0  4 1 0x34325258--         y  y  y     win
0x11 24  0  8  8  8  0 16  0  4 1 0x34325258--         y  y  y     win
0x12 24  0  8  8  8  0 24  0  4 1 0x34325258--         y  y  y     win
0x13 24  0  8  8  8  0 24  8  4 1 0x34325258--         y  y  y     win
0x14 24  0  8  8  8  0 32  0  4 1 0x34325258--         y  y  y     win
0x15 16  0  5  6  5  0  0  0  0 0 0x36314752--         y  y  y     win
0x16 16  0  5  6  5  0 16  0  0 0 0x36314752--         y  y  y     win
0x17 16  0  5  6  5  0 24  0  0 0 0x36314752--         y  y  y     win
0x18 16  0  5  6  5  0 24  8  0 0 0x36314752--         y  y  y     win
0x19 16  0  5  6  5  0 32  0  0 0 0x36314752--         y  y  y     win
0x1a 16  0  5  6  5  0  0  0  4 1 0x36314752--         y  y  y     win
0x1b 16  0  5  6  5  0 16  0  4 1 0x36314752--         y  y  y     win
0x1c 16  0  5  6  5  0 24  0  4 1 0x36314752--         y  y  y     win
0x1d 16  0  5  6  5  0 24  8  4 1 0x36314752--         y  y  y     win
0x1e 16  0  5  6  5  0 32  0  4 1 0x36314752--         y  y  y     win

Wayland platform:
error: XDG_RUNTIME_DIR not set in the environment.
error: XDG_RUNTIME_DIR not set in the environment.
eglinfo: eglInitialize failed

X11 platform:
eglinfo: eglInitialize failed

Device platform:
eglinfo: eglInitialize failed

EGLFS applications are still failing (screenshot below), but I guess this is a step in the right direction.

photo_2021-04-26_23-01-45