Attempting to create a X11 mali interface

Post Reply
crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Attempting to create a X11 mali interface

Post by crashoverride »

Proof-of-concept (POC) X11 GPU render
Image

I have been attempting to create a X11 Mali GPU driver interface. This presents several technical challenges. I finally have something to show for all the research and effort into this. The above image demonstrates the Mali fbdev driver rendering directly to a X11 window using the DRI2 protocol. This POC represents "half" of the required work: a DRI2 enabled X11 DDX. The other 'half' will be the future development of a EGL layer to interface Mali fbdev. I can not guarantee success of this project at this time. However, it looks promising now that I have a POC.

Source code is available but is of no use until the EGL layer is developed. It is provided solely for educational and discussion purposes:
https://github.com/OtherCrashOverride/jem
https://github.com/OtherCrashOverride/x ... fbturbo-n2
These users thanked the author crashoverride for the post:
meveric (Mon Apr 29, 2019 3:39 pm)

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

Very interesting (and useful) project!

BTW, does your "fbturbo" implementation use any 2D hardware(bitblit?) accelerator?

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

odroid wrote:
Mon Apr 29, 2019 10:10 am
does your "fbturbo" implementation use any 2D hardware(bitblit?) accelerator?
No, it does not.

X11 acceleration has its own set of technical challenges. However, the research into this project may be directly applicable to developing an accelerated X11 driver. While a 2D hardware accelerator is available (GE2D), past tests on C2 showed that Mali is much faster. Another major benefit of Mali is that it has a MMU. This allows graphic buffers and blits to use regular virtual memory instead of CMA. The goal would be to integrate Mali fbdev directly into the X11 DDX for 2D acceleration using the same dmabuf infrastructure developed in this project. Although, without a MMU on the display controller, true zero-copy will not be possible as it is on XU4.

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

I see. Thank you for the explanation.

mad_ady
Posts: 8465
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 577 times
Been thanked: 461 times
Contact:

Re: Attempting to create a X11 mali interface

Post by mad_ady »

I was secretly hoping you'd be tinkering to produce something like this...
Kudos to you!

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

The first hardware GLES2 on N2+X11 test using a custom EGL layer I created (libegl_jem.so):
Image

The program running is a Sega Genesis emulator. Other than disabling fullscreen and removing the use of /dev/dri/card0, its unmodified.
https://github.com/OtherCrashOverride/G ... shoverride

* Its currently very slow (40fps).
* Its upside-down.

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

Unmodified glmark2-es2 from Ubuntu repo:
Image

Code: Select all

=======================================================
    glmark2 2014.03+git20150611.fa71af2d
=======================================================
    OpenGL Information
    GL_VENDOR:     ARM
    GL_RENDERER:   Mali-G52
    GL_VERSION:    OpenGL ES 3.2 git.c8adbf9.122c9daed32dbba4b3056f41a2f23c58
=======================================================
[build] use-vbo=false: FPS: 335 FrameTime: 2.985 ms
[build] use-vbo=true: FPS: 384 FrameTime: 2.604 ms
[texture] texture-filter=nearest: FPS: 375 FrameTime: 2.667 ms
[texture] texture-filter=linear: FPS: 375 FrameTime: 2.667 ms
[texture] texture-filter=mipmap: FPS: 379 FrameTime: 2.639 ms
[shading] shading=gouraud: FPS: 369 FrameTime: 2.710 ms
[shading] shading=blinn-phong-inf: FPS: 372 FrameTime: 2.688 ms
[shading] shading=phong: FPS: 360 FrameTime: 2.778 ms
[shading] shading=cel: FPS: 360 FrameTime: 2.778 ms
[bump] bump-render=high-poly: FPS: 290 FrameTime: 3.448 ms
[bump] bump-render=normals: FPS: 395 FrameTime: 2.532 ms
[bump] bump-render=height: FPS: 383 FrameTime: 2.611 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 371 FrameTime: 2.695 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 441 FrameTime: 2.268 ms
[pulsar] light=false:quads=5:texture=false: FPS: 413 FrameTime: 2.421 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 224 FrameTime: 4.464 ms
[desktop] effect=shadow:windows=4: FPS: 217 FrameTime: 4.608 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 58 FrameTime: 17.241 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 61 FrameTime: 16.393 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 71 FrameTime: 14.085 ms
[ideas] speed=duration: FPS: 223 FrameTime: 4.484 ms
[jellyfish] <default>: FPS: 406 FrameTime: 2.463 ms
[terrain] <default>: FPS: 58 FrameTime: 17.241 ms
[shadow] <default>: FPS: 158 FrameTime: 6.329 ms
[refract] <default>: FPS: 76 FrameTime: 13.158 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 392 FrameTime: 2.551 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 395 FrameTime: 2.532 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 392 FrameTime: 2.551 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 393 FrameTime: 2.545 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 395 FrameTime: 2.532 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 394 FrameTime: 2.538 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 391 FrameTime: 2.558 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 393 FrameTime: 2.545 ms
=======================================================
                                  glmark2 Score: 312 
=======================================================
These users thanked the author crashoverride for the post (total 5):
mad_ady (Thu May 09, 2019 10:39 pm) • EarBiteR (Thu May 09, 2019 11:11 pm) • meveric (Fri May 10, 2019 1:53 am) • odroid (Fri May 10, 2019 9:36 am) • mxmilkb (Wed May 15, 2019 5:49 am)

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

Really impressive. :o

User avatar
meveric
Posts: 11159
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 44 times
Been thanked: 399 times
Contact:

Re: Attempting to create a X11 mali interface

Post by meveric »

regarding the flipped picture:

@ptitSeb suggested to look at this code: https://github.com/ptitSeb/gl4es/blob/m ... lx.c#L2486
Maybe it can help fixing this.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

The ideal situation is to eliminate any memory copies. The technical issue preventing this is that I can not get eglCreatePixmapSurface to work (always returns EGL_BADMATCH).

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

PPSSPP and glmark2-es:
Image

The above image shows two GLES2 programs operating at the same time (launched via SSH). Since X11 manages the windows proper (DRI2 without blit/overlay illusions), window overlap, dragging, and mouse clicks work correctly. An additional copy pass was added so the images are now displayed right side up. Not shown is that I also reworked the jem driver to hopefully eliminate kernel panics due to race conditions between the X11 server and client.
These users thanked the author crashoverride for the post (total 4):
meveric (Mon May 20, 2019 4:30 pm) • odroid (Mon May 20, 2019 4:33 pm) • BadPritt (Mon May 20, 2019 10:44 pm) • mad_ady (Mon May 20, 2019 11:33 pm)

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

Wow~~ Glad to see non-flipped multiple GL renderings at the same time. :D
BTW, what is the exact meaning of jem? It must be a gem. ;)

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

GEM is the Linux Graphics Execution Manager. Its described here:
https://www.kernel.org/doc/html/v4.10/g ... anager-gem

DRI2 is a X11 protocol for interfacing direct renderers such as GL/ES and VDPAU. DRI2 was designed to use GEM buffer handles.

Currently, the N2 does not have a KMS/DRM driver and therefore lacks GEM. Previously, ARM's libUMP was used to fill the role that GEM provides, but its also not available on N2. I initially attempted to port libUMP, but there are far too many 32bit hard coded casts that break on a 64bit system. This is the reason I developed JEM (sounds like GEM). When JEM is combined with ION, it fulfills the role that libUMP and GEM provide on other systems. Since ION is handling the buffer allocation and lifecycle, the JEM driver is relatively trivial. It is the "glue" between the X11 server and X11 clients:
https://github.com/OtherCrashOverride/jem
These users thanked the author crashoverride for the post:
xabolcs (Tue May 21, 2019 1:24 am)

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

Thank you for the detail explanation.
I like the glue "JEM" indeed.
It is a brilliant idea to overcome the missing drivers/layers in the current software architecture.

mad_ady
Posts: 8465
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 577 times
Been thanked: 461 times
Contact:

Re: Attempting to create a X11 mali interface

Post by mad_ady »

Great work, as usual crash! Congrats!

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

I could build the JEM driver and have jem.ko file now. :D

Code: Select all

git clone https://github.com/OtherCrashOverride/jem                                                          
cd jem/                                                                                                      
make 
I'm running Ubuntu 18.04 Mate image with Kernel 4.9.177.
Where should I copy the ko driver file to /lib/modules/4.9.177-28/kernel/drivers/ directory?

What is the next step?
Should I build your xf86-video-fbturbo-n2 driver and use the xorg.conf example to configure the N2 X11?
Anyway, I'm trying it even though I don't know what I'm doing.

Code: Select all

sudo apt install xutils-dev xorg-dev
git clone https://github.com/OtherCrashOverride/xf86-video-fbturbo-n2
cd xf86-video-fbturbo-n2/
./autogen.sh
./configure
make
Sorry for bothering you.
I am a very beginner as always. ;)
These users thanked the author odroid for the post:
mad_ady (Tue May 21, 2019 3:15 pm)

mad_ady
Posts: 8465
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 577 times
Been thanked: 461 times
Contact:

Re: Attempting to create a X11 mali interface

Post by mad_ady »

I expect a detailed (or not) magazine article from @crashoverride for this

User avatar
meveric
Posts: 11159
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 44 times
Been thanked: 399 times
Contact:

Re: Attempting to create a X11 mali interface

Post by meveric »

I've created a DKMS package for jem and will attempt to make a package for fbturbo as well (although the later will probably only run for Debian Stretch).

But if you want you can try the DKMS package... I'd actually like to know if it works :)

I've uploaded it to: https://oph.mdrjr.net/meveric/other/N2/

I have to load jem module manually (/etc/modules) and get the /dev/jem device, fbturbo is loaded as well, but it doesn't seem to work for me.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

odroid wrote:
Tue May 21, 2019 2:58 pm
Where should I copy the ko driver file to
I currently do not know the answer to that. I am still in testing and use 'sudo insmod jem.ko' to load it temporarily.
odroid wrote:
Tue May 21, 2019 2:58 pm
What is the next step?
I will attempt to document the requirements here, however, I was not ready for alpha/beta testing yet so there may be omissions and/or future edits to this info.

[IMPORTANT: The mali-fbdev, SDL2, and QT custom packages in the minimal image must be removed and replaced with official Ubuntu packages. This includes installing mesa-gles2 packages as a dependency. While mesa is not used, it is a dependency of most important packages.]

1) Compile and install the jem.ko driver.

2) Set correct permissions for /dev/jem and /dev/ion. They should both be in the 'video' group with +rw access. For testing, its easiest to set full access:

Code: Select all

sudo chmod a+rw /dev/jem
sudo chmod a+rw /dev/ion
3) Compile and install the xf86-video-fbturbo-n2 X11 driver:

Code: Select all

./autogen.sh
./configure --prefix=/usr
make
sudo make install
sudo cp xorg.conf /etc/X11/xorg.conf
4) Copy the libegl_jem.so file (not yet published!) as 'libEGL.so.1.0.0' and set up symlinks:

Code: Select all

lrwxrwxrwx 1 root root     15 Aug 15  2018 /usr/lib/aarch64-linux-gnu/libEGL.so -> libEGL.so.1.0.0
lrwxrwxrwx 1 root root     15 Aug 15  2018 /usr/lib/aarch64-linux-gnu/libEGL.so.1 -> libEGL.so.1.0.0
-rw-r--r-- 1 root root 315792 May 20 17:42 /usr/lib/aarch64-linux-gnu/libEGL.so.1.0.0

lrwxrwxrwx 1 root root 18 Aug 15  2018 /usr/lib/aarch64-linux-gnu/libGLESv2.so -> libGLESv2.so.2.0.0
lrwxrwxrwx 1 root root 18 Aug 15  2018 /usr/lib/aarch64-linux-gnu/libGLESv2.so.2 -> libGLESv2.so.2.0.0
lrwxrwxrwx 1 root root 37 May 10 04:27 /usr/lib/aarch64-linux-gnu/libGLESv2.so.2.0.0 -> /usr/lib/aarch64-linux-gnu/libmali.so
5) Restart X11. The /dev/jem device must be installed prior to starting X11.

Code: Select all

sudo service lightdm restart
6) If using a SSH session, set the DISPLAY environment variable.

Code: Select all

set DISPLAY=:0.0
7) Install glmark2-es2.

Code: Select all

sudo apt install glmark2-es2
If the installation fails, ensure that all custom package files (except kernel) are removed as initially noted.

8) Once glmark2-es has been confirmed to operate properly, other programs may be tested. During testing, I noticed some programs are not properly linked to libEGL.so and may require the use of LD_PRELOAD.

Code: Select all

LD_PRELOAD=libEGL.so programname
These users thanked the author crashoverride for the post:
Payano (Fri Feb 07, 2020 6:41 am)

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

For development, the following mali headers are used:
https://github.com/rockchip-linux/libma ... er/include

Known issues:
* Cache coherency issues may result in 'snow flakes' or jagged images.
* Fullscreen mode is not fully tested.
* Some programs run slow (governor). Using 'taskset' on the official Ubuntu minimal does not work (for unknown reasons). It is necessary to use 'taskset -p [mask] [pid]' to set the CPU affinity after a program is started.

Tested so far:
* Dolphin
- Does not work. It also does not work on N1 (RK3399) so its likely a code issue.

* PPSSPP
- Works
- May require LD_PRELOAD=libEGL.so
- Tested with following 'cmake/Toolchains/odroidn2.armv8.cmake' toolchain file:

Code: Select all

include_directories(SYSTEM
  /usr/include
  /usr/include/EGL
  /usr/include/GLES2
)

set(ARCH_FLAGS "-march=armv8-a+crc -mtune=cortex-a73 -funsafe-math-optimizations")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_FLAGS}"  CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${ARCH_FLAGS}" CACHE STRING "" FORCE)

# set(CMAKE_EXE_LINKER_FLAGS "-L/opt/vero3/lib" CACHE STRING "" FORCE)

set(OPENGL_LIBRARIES /usr/lib/aarch64-linux-gnu/libGLESv2.so)
set(EGL_LIBRARIES /usr/lib/aarch64-linux-gnu/libEGL.so)

set(USING_GLES2 ON)
set(USING_EGL ON)
# set(USING_FBDEV ON)
# set(ARMV7 ON)
# set(FORCED_CPU armv7)
set(USING_X11_VULKAN OFF CACHE BOOL "" FORCE)
* Mupen64Plus
- Works (both rice and glide64mk2)
- Required manually building glide64mk2 (for unknown reasons)

* Reicast
- Works
- Requires build fix

Code: Select all

diff --git a/shell/linux/Makefile b/shell/linux/Makefile
index 355903c0..228070dc 100644
--- a/shell/linux/Makefile
+++ b/shell/linux/Makefile
@@ -129,11 +129,12 @@ else ifneq (,$(findstring x64,$(platform)))
 # Generic 64 bit ARM (armv8) Linux
 else ifneq (,$(findstring arm64,$(platform)))
     NOT_ARM := 1
-    USE_X11 := 1
+    USE_SDL := 1
     ARM64_REC := 1
     ISARM64 := 1
     CFLAGS += -D TARGET_LINUX_ARMv8 -D TARGET_NO_AREC -fno-builtin-sqrtf
     CXXFLAGS += -fexceptions
+    USE_GLES := 1
 
 # Generic 32 bit ARMhf (a.k.a. ARMv7h)
 else ifneq (,$(findstring armv7h,$(platform)))

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

Appreciate your efforts.
I can wait until you are ready for public testing.

User avatar
meveric
Posts: 11159
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 44 times
Been thanked: 399 times
Contact:

Re: Attempting to create a X11 mali interface

Post by meveric »

crashoverride wrote:
Tue May 21, 2019 5:00 pm
Tested so far:
* Dolphin
- Does not work. It also does not work on N1 (RK3399) so its likely a code issue.
Just to correct this, Dolphin works on the ODROID N1: viewtopic.php?p=217911#p217911
But it has some graphical issues which are related to the Mali GPU which is not very well supported in the Dolphin project.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

meveric wrote:
Wed May 22, 2019 1:35 am
Dolphin works on the ODROID N1
I compiled master from github yesterday. It runs but the screen is just a solid color. I know I have used it before on Firefly RK3399 (years ago?) so I think recent changes have caused it to stop working. Any tips for getting it running on N1 appreciated (last know working commit?). N1 is my reference for what is 'correct' operation to expect on N2.

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

I spent the day trying to implement GE2D blit hardware acceleration. Despite the effort, I was not able to get GE2D to correctly blit from an ION buffer. The 4.9.y-upstream kernel branch was also tested since it implements GE2D patches. This did not function correctly either. Due to this, I am dropping GE2D support as a planned feature. I will need to create some stand alone test programs to illustrate the issues with GE2D on N2 so hopefully Amlogic can fix it.

User avatar
meveric
Posts: 11159
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 44 times
Been thanked: 399 times
Contact:

Re: Attempting to create a X11 mali interface

Post by meveric »

crashoverride wrote:
Wed May 22, 2019 1:56 am
I compiled master from github yesterday. It runs but the screen is just a solid color. I know I have used it before on Firefly RK3399 (years ago?) so I think recent changes have caused it to stop working. Any tips for getting it running on N1 appreciated (last know working commit?). N1 is my reference for what is 'correct' operation to expect on N2.
Last one I tested was 5.0-7441 commit (99dff10d43) https://oph.mdrjr.net/meveric/other/N1/
I think you're correct that they changes something afterwards.. let me see if I can get the latest to work on N1.

Ah yes, one of the biggest changes was change to Qt 5.9 as a requirement, which I don't have for Debian Stretch. So I can only use a build that still supports Qt 5.7

Edit:
Just compiled: 74899e417bb0bce222a3c5cea995fd626bc61e18 5.0-8386
latest without Qt 5.9 worked fine as well on N1 uploaded it to the same folder.
Edit 2:
Qt 5.9 is exaggerated.
I've been building newer versions of dolphin and each one so far works fine with Qt 5.7 so they just put a requirement in there that is not required it seems, which is very annoying.
I'll keep trying to see how far I can get.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

Dolphin on N2
Image

The issues affecting it are unique to N2:
1) It uses eglGetProcAddress to find core API entry points instead of using the linker. This caused it to use libmali.so instead of libegl_jem.so. I changed libegl_jem to detect this.
2) It blindly uses the first config that is returned. On bifrost, this is a R10, G10, B10, A2 (10bit color) surface that can not be used with external buffers. This currently requires a patch to Dolphin. I will attempt to compensate for it libegl_jem.

Thanks to @meveric for assistance.

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

You made it again :o

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

I managed to implemented cache coherency. This resolves the 'snow flake' issue (not visible in screen shots). I also implemented eglSwapInterval for VSYNC. However, as noted in another thread, the timing is "whacky". This brings the project to the point where its time to resolve external issues since I am now creating workarounds for the workarounds. ;)

What needs fixing outside:
1) eglCreatePixmapSurface - This function currently does not work. It has the single largest impact on performance and design of the software.
2) GE2D - Blitting from ION buffers currently does not work properly. This impacts performance as the CPU is now (slowly) copying surfaces.
3) VSYNC - This function appears to have unstable timing. This makes presenting 'tare free' unpredictable.

User avatar
odroid
Site Admin
Posts: 35301
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 1089 times
Been thanked: 825 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroid »

I love the term workarounds for the workarounds.
Seems to be very close to start a beta test event :twisted:

How about assigning the xorg stuff to the big-cores to improve the timing issue?
viewtopic.php?f=177&t=34963

Kernel
Posts: 32
Joined: Sun May 05, 2019 2:23 am
languages_spoken: english
ODROIDs: C1, C2, N2
Has thanked: 18 times
Been thanked: 4 times

Re: Attempting to create a X11 mali interface

Post by Kernel »

:shock: Very impressive work! :)

mad_ady
Posts: 8465
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 577 times
Been thanked: 461 times
Contact:

Re: Attempting to create a X11 mali interface

Post by mad_ady »

I fear this gem :ugeek: might get lost from public memory.
Latest reports showed that it mostly works. I'm curious if kodi plays well with it on X11.
Hardkernel might want to package it (maybe as part of odroid-config?) for others to use.

Even if it's not a perfect solution yet, it doesn't mean it won't be useful.

So *BUMP* :)

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

I was hoping to revisit this once a 5.x kernel became LTS. A DRM enabled kernel would obsolete the fbdev version of a X11 driver, but the current DRM driver has too many issues (noted in another forum thread). Now, it appears the 5.x "LTS" kernel only has a two year life. This means that nobody outside of x86 will adopt it because it will be EOL before any ARM based products hit the market using it.

I am thinking it may still be worthwhile attempting a 5.x DRM enabled X11 driver. However, I will need a fork that supports the ARM GPU driver instead of the Panfrost driver which is currently useless on Mali-G52.

odroidn2user
Posts: 327
Joined: Fri Oct 25, 2019 4:14 pm
languages_spoken: english
ODROIDs: N2, C4
Has thanked: 91 times
Been thanked: 87 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroidn2user »

crashoverride wrote:
Mon Sep 16, 2019 8:35 am
I was hoping to revisit this once a 5.x kernel became LTS. A DRM enabled kernel would obsolete the fbdev version of a X11 driver, but the current DRM driver has too many issues (noted in another forum thread). Now, it appears the 5.x "LTS" kernel only has a two year life. This means that nobody outside of x86 will adopt it because it will be EOL before any ARM based products hit the market using it.

I am thinking it may still be worthwhile attempting a 5.x DRM enabled X11 driver. However, I will need a fork that supports the ARM GPU driver instead of the Panfrost driver which is currently useless on Mali-G52.
Hiya Crashoverride, any chance you could post your insights with regards to the Meson 5.x DRM driver and your X11 mali interface, now that the new DRM driver is actually available?
It seems you were perhaps further along to an accelerated desktop than the other projects?

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

odroidn2user wrote:
Mon Jan 13, 2020 10:35 pm
now that the new DRM driver is actually available?
The ARM Mali driver (not panfrost) also needs to be available (and associated libmali.so, not mesa). I am not sure what the current status of this integration is.

odroidn2user
Posts: 327
Joined: Fri Oct 25, 2019 4:14 pm
languages_spoken: english
ODROIDs: N2, C4
Has thanked: 91 times
Been thanked: 87 times
Contact:

Re: Attempting to create a X11 mali interface

Post by odroidn2user »

crashoverride wrote:
Tue Jan 14, 2020 9:03 am
odroidn2user wrote:
Mon Jan 13, 2020 10:35 pm
now that the new DRM driver is actually available?
The ARM Mali driver (not panfrost) also needs to be available (and associated libmali.so, not mesa). I am not sure what the current status of this integration is.
Based on what I read, I thought I understood that you wrote an X11 'driver' directly interacting with the DRM kernel module? But I understand now that your X11 driver interacted with libmali ?

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

The linux rendering architecture is multifaceted: it takes many things coming together to work. This thread discusses the development of an EGL X11 compatibility layer. This requires a presentation layer (framebuffer or DRM), a X11 DDX (fbturbo, armsoc, modestting), and a GPU interface (libmali). The EGL X11 compatibility layer provides the necessary API support (DRI2) to interface a DDX with the GPU.

jgmdev
Posts: 139
Joined: Tue Jan 28, 2020 2:28 pm
languages_spoken: english, spanish
ODROIDs: U2, N2, N2+, C4
Has thanked: 39 times
Been thanked: 80 times
Contact:

Re: Attempting to create a X11 mali interface

Post by jgmdev »

crashoverride wrote:
Tue May 21, 2019 4:40 pm
...
4) Copy the libegl_jem.so file (not yet published!) as 'libEGL.so.1.0.0' and set up symlinks:
...
Will you be publishing that libegl_jem code at some point for other people to play? Even if not perfect it would open up the possibilities for those of us that prefer to stick with xserver. I tested the mali drivers with weston under archlinuxarm and while it offers more graphical smoothness the responsiveness of the system is kind of slower than running a desktop environment like xfce or mate with xserver...

mad_ady
Posts: 8465
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 577 times
Been thanked: 461 times
Contact:

Re: Attempting to create a X11 mali interface

Post by mad_ady »

Not to mention - it would be interesting to see how this would work on C4

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

jgmdev wrote:
Sun Apr 26, 2020 2:22 pm
Will you be publishing that libegl_jem code at some point for other people to play?
With the release of the C4, I have plans to revisit this. I can not make any guarantees, though.
These users thanked the author crashoverride for the post (total 2):
rooted (Tue Apr 28, 2020 2:19 pm) • odroidn2user (Thu Apr 30, 2020 3:06 am)

jgmdev
Posts: 139
Joined: Tue Jan 28, 2020 2:28 pm
languages_spoken: english, spanish
ODROIDs: U2, N2, N2+, C4
Has thanked: 39 times
Been thanked: 80 times
Contact:

Re: Attempting to create a X11 mali interface

Post by jgmdev »

crashoverride wrote:
Mon Apr 27, 2020 8:47 pm
With the release of the C4, I have plans to revisit this. I can not make any guarantees, though.
That would be great, this project may help in running partially accelerated compiz which I read supports egl backend since 0.9.8, that may give X users the posibility of some accelerated desktop :)

Just in case here is the compiz Opengl Es announcement
https://launchpad.net/compiz/0.9.8/0.9.8.0

Another edit to point out that the archlinux AUR compiz package https://aur.archlinux.org/packages/compiz/ has patches that cleans it from unity stuff and only the -DBUILD_GLES=On flag has to be specified to enable GLES and remove the -DCOMPIZ_DEFAULT_PLUGINS flag just in case...
These users thanked the author jgmdev for the post:
odroidn2user (Thu Apr 30, 2020 3:06 am)

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

jgmdev wrote:
Thu Apr 30, 2020 12:55 am
this project may help in running partially accelerated compiz which I read supports egl backend since 0.9.8
https://ubuntu-mate.org/blog/ubuntu-mat ... ase-notes/
Compiz and Compton have been removed from the default Ubuntu MATE install. The fundamental reasons for including them no longer exist.
[edit]
Note the compiz 0.9.8 release is dated 2012-08-27 (almost a decade ago).

jgmdev
Posts: 139
Joined: Tue Jan 28, 2020 2:28 pm
languages_spoken: english, spanish
ODROIDs: U2, N2, N2+, C4
Has thanked: 39 times
Been thanked: 80 times
Contact:

Re: Attempting to create a X11 mali interface

Post by jgmdev »

crashoverride wrote:
Thu Apr 30, 2020 6:12 am
Note the compiz 0.9.8 release is dated 2012-08-27 (almost a decade ago).
I build it today latest 0.9.14 and still has support for OpenGL ES. Tried it with plain mesa (llvmpipe) but complained about:
compiz (opengl) - Fatal: GL_OES_EGL_image is missing
Maybe Mali has support for that extension...

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

jgmdev wrote:
Thu Apr 30, 2020 6:33 am
Maybe Mali has support for that extension...
Mali does support the EGL_image extension. However, compiling compiz is outside the scope of this topic. A new forum topic should be created to discuss that.

jgmdev
Posts: 139
Joined: Tue Jan 28, 2020 2:28 pm
languages_spoken: english, spanish
ODROIDs: U2, N2, N2+, C4
Has thanked: 39 times
Been thanked: 80 times
Contact:

Re: Attempting to create a X11 mali interface

Post by jgmdev »

I guess this is pretty much old news on the forum but https://github.com/ptitSeb/gl4es paired with the work on this wrapper would mostly be all we need to have a working GL v2 for accelerated X11 desktop :)

User avatar
meveric
Posts: 11159
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105), GoA, C4
Has thanked: 44 times
Been thanked: 399 times
Contact:

Re: Attempting to create a X11 mali interface

Post by meveric »

jgmdev wrote:
Thu May 07, 2020 7:50 am
I guess this is pretty much old news on the forum but https://github.com/ptitSeb/gl4es paired with the work on this wrapper would mostly be all we need to have a working GL v2 for accelerated X11 desktop :)
gl4es works on X11 without this.
You can use LIBGL_FB=1 to run X11 application in an fullscreen X11 window that is rendered in fbdev and everything works.
You can even use LIBGL_FB=3 to run directly in a window but it looses quite a bit of performance.
It works since it uses GLX instead and doesn't need EGL->X11 in that case.

I even wrote an article about this many months ago already:
https://magazine.odroid.com/article/lin ... d-gl4es/11
These users thanked the author meveric for the post:
jgmdev (Thu May 07, 2020 1:16 pm)
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

jgmdev
Posts: 139
Joined: Tue Jan 28, 2020 2:28 pm
languages_spoken: english, spanish
ODROIDs: U2, N2, N2+, C4
Has thanked: 39 times
Been thanked: 80 times
Contact:

Re: Attempting to create a X11 mali interface

Post by jgmdev »

crashoverride wrote:
Mon May 20, 2019 4:04 pm
...
The above image shows two GLES2 programs operating at the same time (launched via SSH). Since X11 manages the windows proper (DRI2 without blit/overlay illusions), window overlap, dragging, and mouse clicks work correctly. An additional copy pass was added so the images are now displayed right side up.
...
Can you share how you fixed the flipped rendering issue? wlroots has the same issue which causes applications like mpv and glmark2-es2-wayland to render upside-down and mirrored. I patched wlroots to work with libMali gbm/wayland driver (for another issue) with a pull request from another user for the wayfire odroid n2 image I shared, since that pull request was not merged because they are against closed source binary drivers. Wlroots developers are against implementing workarounds for closed source drivers, so I imagine that in order to make the rendering properly work one would have to patch it manually since upstream may not merge the change or find a fix for the issue.

Since I'm ignorant about GL and EGL graphics stuff I don't know how to fix the flipped rendering my self and you guys seem to already know how to fix it, so that is why I'm asking for some sample code that I could use as base to then fix the wlroots issue (even thought I'm not even sure where in the wlroots code base the change should take place, but that would be part of the task). Another option would be to see how weston or gnome shell do it (since they both render correctly) but I don't even know where to look at :(

crashoverride
Posts: 5102
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 366 times
Contact:

Re: Attempting to create a X11 mali interface

Post by crashoverride »

jgmdev wrote:
Wed Jun 03, 2020 5:07 am
Can you share how you fixed the flipped rendering issue?
A second render pass was added using inverted texture coordinates.
jgmdev wrote:
Wed Jun 03, 2020 5:07 am
wlroots has the same issue which causes applications like mpv and glmark2-es2-wayland to render upside-down and mirrored.
If I recall correctly, Mesa added a custom EGL/GL extension to flip the Y axis. It is proprietary to Mesa and not part of the Khronos requirements. Therefore, its unlikely that any other vendor (like ARM) will support it.

jgmdev
Posts: 139
Joined: Tue Jan 28, 2020 2:28 pm
languages_spoken: english, spanish
ODROIDs: U2, N2, N2+, C4
Has thanked: 39 times
Been thanked: 80 times
Contact:

Re: Attempting to create a X11 mali interface

Post by jgmdev »

crashoverride wrote:
Thu May 09, 2019 3:17 pm
* Its currently very slow (40fps).
I posted this somewhere else but just in case if not known yet... When playing around with the mali fbdev driver and gl4es I also noticed all applications where rendering at ~40FPS and discovered that forcing the refresh rate of the display to 60 using the xorg configuration files caused an increase to ~70FPS for same applications that where capped at ~40FPS. So it seems that some how the mali fbdev driver forces vsync internally. Sharing in case it may be useful to know.
These users thanked the author jgmdev for the post:
Luke.go (Thu Jun 04, 2020 10:08 am)

Post Reply

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest