Showing posts with label OpenGL ES. Show all posts
Showing posts with label OpenGL ES. Show all posts

Sunday, April 10, 2016

Compatible OpenGL / OpenGL ES games on i.MX6

If you happen to have an ARM development board sitting around, you may be thinking about plugging it into your nearest HDTV to play some games. While the ultimate gaming computer is probably not going to be built around a single-board computer such as ODROID or Raspberry PI, it might be interesting to see what such a device is capable of. I was looking for games that would utilize the OpenGL|ES capability provided by the i.MX6Q processor, but there aren't that many compatible Linux games out there, with most still using the standard "desktop" OpenGL. Many of the similar ARM SOCs provide only GL|ES and do not support OpenGL at all, but the i.MX6Q at least supports some part of the OpenGL 2.1 specification. To help me keep track of the results, I started creating my own "ultimate guide" for GL/GL|ES compatible games on i.MX6Q and maybe others might find this information useful as well.

In order to make my list, I require that the game will run full-screen with "reasonable" FPS, and utilize the hardware GL or GL|ES capability of the i.MX6Q (refer to my previous posts how the system is setup). However, on the Sabre Lite and SabreSD boards that I'm using, I found that many of these games don't set the video mode properly, but it can be done manually using xrandr prior to running the game. I am also trying to keep track of some different monitors that I am using (a 4:3 A/R Dell, a 1920x1080 RCA HDTV, and our new 55" Samsung HDTV), as the aspect ratio may affect what modes are available to the game.

As I mentioned in the introduction above, I found only a couple of games so far that are using GL|ES graphics on Linux, these are:
  • Trigger Rally, ported to OpenGL|ES by ptitSeb (libGLES_CM)
  • Hurrican, ported by pickle (libGLESv2)

The i.MX6Q supports at least a part of OpenGL 2.1 and I have found a half dozen or so titles that are compatible, including an early version of Neverball. I have found quite a few more games that will run if linked to a special implementation of libGL called glshim. The glshim library was devised by lunixbochs for the purpose of "providing OpenGL 1.x functionality to OpenGL ES accelerated cards" (and thus to to expand the available games for the Pandora ... and possibly other platforms). As stated glshim provides "parts of OpenGL 1.x by internally translating to OpenGL ES". By now, glshim has found its way from the Pandora world to other ARM platforms such as Odroid, and i.MX6. I am using the ptitseb branch as I found it would allow a few games to run that the lunixbochs version wouldn't, but at this time I have not bothered to see what the functional differences are between the two versions.

Running the game executable with glshim may be as simple as invoking it with LD_CONFIG_PATH. However, I seem to find that I have to re-link the executable, else it tends to defer to the libGL.so which is already installed on my system. This is easily done be replacing '-lGL' with e.g. '/usr/local/lib/glshim/libGL.so' in the link command.

One final comment is that out of the dozen or so games that I have built and found working with glshim, all are using libSDL-1.2, with the exception of CaveExpress (libSDL2-2.0). 

Enjoy!

Monday, February 29, 2016

Trigger Rally GL|ES on i.MX6Q

Trigger Rally, "a fast-paced free software rally racing game", was ported some time ago to OpenGL|ES on Open Pandora by ptitSeb. Here's a link to the SourceForge browser at Revision: 96 where the Pandora branch was made. With a bit of additional footwork, I was able to build it on an i.MX6 quad-core and it seems to run pretty well. Trigger Rally has undergone considerable development since that branch was made, so it might be a good exercise to forward-port those GL|ES patches to the current version! 

Build Environment
The build environment is hosted on an i.MX6 quad-core platform running Debian “jessie” release. The system relies on closed-source VIVANTE GPU libraries for Freescale i.MX6 being installed. Please see previous posts for details on setting up the root file system to support accelerated GL/GLES functionality in Debian.


Prerequisite  Binary Packages
apt-get install cmake jam libsdl-image1.2-dev libopenal-dev libalut-dev libphysfs-dev

Build GLU ES 
TR depends on GLU ES implementation (gluScaleImage) - latest source ported by lunixbochs (GLU ES version 1.5 based on original GLU 1.3) is on GitHub. 

git clone https://github.com/lunixbochs/glues.git
cd glues ; rm -f CMakeCache.txt ; cmake . ; make

If the build is successful, the library file libGLU.so.1 will have been created. There is no install target - maybe there is better way, but I simply copy the two needed header files so they will be found by the build in a system include path:

cp lunixbochs/glues/source/glues.h  /usr/local/include/GLES/
cp lunixbochs/glues/include/SDL/SDL_opengles.h  /usr/local/include/SDL/

Build TR
Define LINUX in trigger-rally-pandora/Jamrules; otherwise header file /usr/include/EGL/eglvivante.h (part of Freescale imx-gpu-viv bundle) throws an #error "Platform not recognized":

sed -i 's/COMPILER_CFLAGS += -Wall/COMPILER_CFLAGS += -Wall -DLINUX=1/' Jamrules

Please note that this project uses jam (and not make) as build tool:
./configure ; jam

If you did not copy over the header files from GLU ES, you are probably seeing a couple of errors from the build:

src/pengine/pengine.h:39:24: fatal error: GLES/glues.h: No such file or directory

/usr/local/include/GLES/glues.h:37:33: fatal error: SDL/SDL_opengles.h: No such file or directory

Eventually, the linker fails due to library specification -lGLUES_CM:

/usr/bin/ld: cannot find -lGLUES_CM
collect2: error: ld returned 1 exit stat

Rather than take the time to tweak the jam scripts to fix the problem correctly, immediate gratification is had by manually linking the trigger executable in the shell: remove -lGLUES_CM from the linker invocation, as well as the library path specification -L/usr/lib/arm-linux-gnueabihf, and link directly to the GLU  ES library libGLU.so.1 as follows:

g++ -Wall -DLINUX=1 -O3   -DDATADIR='"${prefix}/share"' -DHAVE_GLES -DPANDORA  -o trigger ./out/armv7l-unknown-linux-gnu/opt/src/trigger/eglport.o ./out/armv7l-unknown-linux-gnu/opt/src/trigger/game.o ./out/armv7l-unknown-linux-gnu/opt/src/trigger/main.o ./out/armv7l-unknown-linux-gnu/opt/src/trigger/render.o ./out/armv7l-unknown-linux-gnu/opt/src/trigger/menu.o  ./out/armv7l-unknown-linux-gnu/opt/src/pengine/libpengine.a ./out/armv7l-unknown-linux-gnu/opt/src/psim/libpsim.a   -lSDL -lSDL_image -lEGL -lGLES_CM  -lopenal -lalut -lphysfs ../glues/lunixbochs/glues/libGLU.so.1 

(use jam -n to get the g++ command)

Success!
No need to run the make install, the trigger executable will run fine if invoked from within the project "./data" directory:

cd data ; ln -s ../trigger

xrandr -s 800x600   # TODO: it can't seem to change resolution on it's own!
LIBGL_DEBUG=verbose ./trigger



Enjoy!

Tuesday, January 26, 2016

Hurrican 2D Platformer on i.MX6 Sabrelite

Hurrican is a retro/16-bit styled 2D platformer that I was able to build from source on an i.MX6 Sabrelite board with essentially zero effort, as it has already been ported to SDL 1.2 and GLES2.

Some background info may be of interest on the forum posting at Phoronix. Apparently Hurrican was entirely a Windoze game ported to Linux-SDL-GL by pickle who is pretty active on the Open Pandora Pyra community, which I have been looking at quite a bit lately to research games and GL stuff to try out on the i.MX6 board.

This one builds and runs "out of the box" as they say on my system, with great sound music, keyboard control and no obvious glitches.

Repository Root: svn://svn.code.sf.net/p/hurrican/code

sdl1.2 is installed from the distribution and apparently with GLES2 target enabled ...

apt-get install libsdl-mixer1.2-dev libsdl-image1.2-dev libsdl1.2-dev libmodplug-dev
cd hurrican-code/Hurrican/src/
make TARGET=linux_GL2  # this will link with -lGLESv2

I should get a screenshot of the thing running but even better is gratuitous nerdy console output showing all the startup logging gotta love it ...



More info on Hurrican over at Odroid forum.









Monday, January 25, 2016

mesa demos revisited on i.MX6

In my quest to better understand GL/GLES I previously setup an Debian environment on i.MX6 and installed Freescale support libraries to enable hardware accelerated GL functionality.

Download source for mesa-demos-8.3.0.

Build is done in native armhf environment on the i.MX6 Sabre-lite. With usr libraries and headers installed, the following error is seen in the build:

 /usr/include/EGL/egl.h:39,
                 from eglut.c:32:
/usr/include/EGL/eglvivante.h:242:2: error: #error "Platform not recognized"
 #error "Platform not recognized"

Use the following configure to define platform LINUX:

CFLAGS=-DLINUX ./configure --enable-vg=no

(configure detects "vg" available on my system but throws many compile errors which I don't care to deal with for now so use --enable-vg=no   to avoid additional errors)

The following modules are automatically enabled from the above configure line ... one outcome I didn't check for was situation with GL support (what any header files are supplied with support libraries):
checking for GLEW... yes
checking for GLU... yes
checking for EGL... yes
checking for GLESV1... yes
checking for GLESV2... yes
checking for OSMESA... no
checking for DRM... yes
checking for X11... yes
checking for GBM... yes
checking for FREETYPE2... yes

The following error is seen in the build  ... assume at least in this case it is a benign side affect of co-mingling locally built packages with chip vendor support libraries:

/usr/bin/ld: warning: libGL.so.1, needed by /usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/libGLEW.so, may conflict with libGL.so.1.2

Demos in src/egl/opengles1, src/egl/opengles2 working.
Some in src/demos working, some not, some real slow.
Most in src/tests apparently not ... glutfx full screen but otherwise not interesting.
I noticed from eglinfo that there is no 'gl' context so don't expect anything from src/egl/opengl to work.

debian@arm:~/src/mesa/mesa-demos-8.3.0/src/egl/opengl$ DISPLAY=:0 LIBGL_DEEBUG=verbose ./eglinfo -info
EGL API version: 1.4
EGL vendor string: Vivante Corporation
EGL version string: 1.4
EGL client APIs: OpenGL_ES OpenVG
EGL extensions string:
    EGL_KHR_reusable_sync EGL_KHR_fence_sync EGL_KHR_image
    EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image
    EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image
    EGL_KHR_lock_surface EGL_KHR_create_context
    EGL_EXT_create_context_robustness EGL_EXT_buffer_age
EGL client extensions string:
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 12  0  4  4  4  0  0  0  0 0 0x21--      a     y  y     win,pb
0x02 12  0  4  4  4  0  0  8  0 0 0x21--      a     y  y     win,pb


src/xdemos/glxgears is good to go: 

debian@arm:~/src/mesa/mesa-demos-8.3.0/src/xdemos$ DISPLAY=:0 LIBGL_DEBUG=verbose ./glxgears
libGL: OpenDriver: trying /usr/lib/dri/vivante_dri.so
drmOpenByBusid: Searching for BusID platform:Vivante GCCore:00
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 4, (OK)
drmOpenByBusid: drmOpenMinor returns 4
drmOpenByBusid: drmGetBusid reports platform:Vivante GCCore:00
748 frames in 5.0 seconds = 149.467 FPS
752 frames in 5.0 seconds = 150.196 FPS
^CProcess termination by interupt!
debian@arm:~/src/mesa/mesa-demos-8.3.0/src/xdemos$   


This patch against mesa-demos-8.3.0 incorporates these various hacks and fixes including one known issue regarding undefined reference to `glWindowPos2iARB'.



Good luck!

Saturday, January 9, 2016

Debian on i.MX6q with GL/GLES

Update notes from previous post - install root file system on i.MX6 from Debian jessie distro and configure GL/GLES. Other people got this working a while before I did so it's mostly a matter of putting all various notes in order. To begin with, keeping links to a few references handy, some resources require registration on Freescale website (as of about 12/2015 will need to update links to NXP domain).

Setup root filesystem

This is for system boot from SD card - with the card already prepped i.e. partitioned, bootloader intsalled, ext4 fs, and mounted e.g. /dev/sda. A suitable debootstrap command to install base Debian root filesystem onto SD card might be:

sudo debootstrap jessie  /media/sda1

On the SabreSD board, I have upgraded to kernel imx_3.14.38_6qp_ga (link to source snapshot tarballs) ... this kernel provides Galcore version 5.0.11. To configure the kernel, I start with 'make imx_v7_defconfig', then make the following additions to .config:

 CONFIG_DRM=m
 CONFIG_DRM_VIVANTE=m

 CONFIG_FHANDLE=y
 CONFIG_EXPORTFS=y
 CONFIG_DEBUG_LL=y
 CONFIG_DEBUG_IMX6Q_UART=y
 CONFIG_EARLY_PRINTK=y

 CONFIG_USB_SERIAL_PL2303=m  # a Prolific USB serial port I'm using

Finish kernel installation to rfs:
 cp arch/arm/boot/zImage  arch/arm/boot/dts/imx6q-sabresd.dtb  /boot/
 echo vivante >> /mnt/sda/etc/modules

Install udev rules configuration file for imx (allow group access to /dev/galcore):
 cp 10.imx-rules /etc/udev/rules.d

Reboot, confirm modules loaded (vivante, drm):
dmesg  | grep Galcore
[    2.421028] Galcore version 5.0.11.33433
ls -l /dev/galcore 
 crw-rw---- 1 root video 199, 0 May 12 21:48 /dev/galcore

I built patched .deb packages for libdrm, mesa, xorg-server to incorporate a critical patch from Freescale for the i.MX6. The idea is that only the packages affected by xfor86drm.h are locally built, and the rest installed from Debian distribution as normal. (Run grep across sources of libdrm, mesa, and xorg-server to see affected files). I'm sure there are more elegant strategies to finesse the local built packages onto the system, but here is a series of commands below demonstrate one attempt to install distribution packages along with local built .debs in the right order to meet package dependencies.  Note -provide simple compile link test for DRM_CAS  defined for arm in running system as well as build environments). Also note latest versions, at this time running X.org X Server 1.16.4 - which seems to work perfectly well without any noticeable incompatibilies (refer to comments regarding Vivante EXA driver below and ignore any instructions on my old blogs to pin the distribution to any previous iteration of snapshot.debian.org).

Create entries in /etc/apt/preferences.d to make apt respect locally built/installed packages e.g. essentially enumerating all the local  debuilded .deb packages:

sabrehd@sabresd:~$ find /etc/apt/preferences.d/
/etc/apt/preferences.d/
/etc/apt/preferences.d/libdrm
/etc/apt/preferences.d/xorg-server
/etc/apt/preferences.d/mesa

Versions of local packages built installed with dpkg and packages apt-getted are all as downloaded  from http://ftp.us.debian.org/debian at the time this system was built and indicated in commands below. To being with, all can be installed from libdrm even though the drm drivers installed have nothing to do with the arm architecture but are harmless and still needed by other modules on the sytem anyway ... dpkg -i `ls libdrm/*\.deb` is of course one way to do it or you could try:

 dpkg -i ./libdrm-freedreno1_2.4.58-2_armhf.deb  libdrm-nouveau2_2.4.58-2_armhf.deb  libdrm-radeon1_2.4.58-2_armhf.deb  libdrm2_2.4.58-2_armhf.deb

At the end there should be a nice xfce4 desktop (a little script might be nice here):

 apt-get  install libllvm3.5  libexpat1 libelf1

 dpkg -i  mesa/libgl1-mesa-dri_10.3.2-1+deb8u1_armhf.deb

 apt-get   install x11-common   libxaw7 libxkbfile1 libxt6 libepoxy0 libpciaccess0 libpixman-1-0 libxfont1 libxshmfence1    xkb-data x11-xkb-utils

 dpkg -i xorg-server/xserver-common_1.16.4-1_all.deb

 apt-get  install keyboard-configuration libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-sync1 libxdamage1 libxfixes3 libxxf86vm1   libxcb-render0 libxcb-shape0 libxcb-xfixes0   libwayland-client0 libwayland-server0

 dpkg -i mesa/libglapi-mesa_10.3.2-1+deb8u1_armhf.deb
 dpkg -i mesa/libgbm1_10.3.2-1+deb8u1_armhf.deb
 dpkg -i mesa/libgl1-mesa-glx_10.3.2-1+deb8u1_armhf.deb
 dpkg -i mesa/libegl1-mesa_10.3.2-1+deb8u1_armhf.deb
 dpkg -i ./xorg-server/xserver-xorg-core_1.16.4-1_armhf.deb

 apt-get install  xserver-xorg-video-fbdev xserver-xorg xinit
 apt-get install xfce4

It should be possible to startx at this point. However there are more dev packages to be installed as  the EXA driver for Vivante GPU is also going to be native-built on this system farther below - it's not necessary to native build it (I just don't bother setting up cross-tools), but it must be built I think against the version of X.org release intending to run on the rfs.

 apt-get install libpixman-1-dev x11proto-core-dev x11proto-input-dev x11proto-xext-dev x11proto-video-dev x11proto-randr-dev  x11proto-render-dev x11proto-dri2-dev  x11proto-gl-dev

 apt-get install  x11proto-fonts-dev x11proto-xinerama-dev  x11proto-kb-dev x11proto-xf86dri-dev x11proto-resource-dev x11proto-scrnsaver-dev  x11proto-xf86bigfont-dev  x11proto-dri3-dev x11proto-present-dev

 apt-get install libxkbfile-dev libpciaccess-dev

 dpkg -i ./mesa/mesa-common-dev_10.3.2-1+deb8u1_armhf.deb
 dpkg -i xorg-server/xserver-xorg-dev_1.16.4-1_armhf.deb

Here is the origin of most of the complexity of this system! Note the locations of packages to installed from the FSL Community BSP which can also slightly more conveniently be download directly from yocto project:

http://downloads.yoctoproject.org/mirror/sources/
http://downloads.yoctoproject.org/mirror/sources/xserver-xorg-video-imx-viv-5.0.11.p7.1.tar.gz
http://downloads.yoctoproject.org/mirror/sources/imx-gpu-viv-5.0.11.p7.1-hfp.bin

xserver-xorg-video-imx-viv is source code of Vivante EXA driver (build steps to follow in sections below). imx-gpu-viv is Freescale's implementation of GL/GLES associated runtime libraries and development headers and more or less takes the place of any existing libdrm and mesa implementations on the system - therefore it is likely that installed versions of some of these libs and header files are already on the system. Note that Debian the package management system already installs libGL* and friends to /usr/lib/arm-linux-gnueabihf/, while imx-gpu-viv will wind up in base of /usr/lib which as higher search precedence with ldconfig (the distro versions are not removed).

I used tar to create an archive of imx-gpu-viv-5.0.11.p7.1-hfp/gpu-core/usr/ and to extract the contents over the /usr/ filesystem e.g. resulting in /usr/lib/libGL.so etc. The updated header files are found in /usr/include/GL (should not have any mesa dev packages installed from the distro).

Explanation for the sym-linking scheme, which is done as a way to switch between X11, Wayland or framebuffer versions of the libraries, seems to have been dropped from recent versions of the documentation (i.MX 6Dual/6Quad Linux Reference Manual, Rev. L3.0.35_4.1.0 page 81) but most people in i.MX6 land seem to already be aware of it by now.

On X11 systems, the symbolic links to these libraries need to be redirected. This can be
done using the following sequence of commands:

> cd /usr/lib
> sudo ln -s libGAL-x11.so libGAL.so
> sudo ln -s libEGL-x11.so libEGL.so
> sudo ln -s libEGL-x11.so libEGL.so.1
> sudo ln -s libVIVANTE-x11.so libVIVANTE.so

On directFB backend, the symbolic links to these libraries need to be redirected. This can
be done using the following sequence of commands:

> cd /usr/lib
> sudo ln -s libGAL-dfb.so libGAL.so
> sudo ln -s libEGL-dfb.so libEGL.so
> sudo ln -s libEGL-dfb.so libEGL.so.1
> sudo ln -s libVIVANTE-dfb.so libVIVANTE.so

Note dpkg apt and company have an annoying habit of completing package installs with an invocation of ldconfig which clobbers the links ("sbin/ldconfig.real: /usr/lib/libOpenVG.so is not a symbolic link").

By changing the sim links it should be possible to run some demos on the framebuffer display (imx-gpu-viv-5.0.11.p7.1-hfp/gpu-demos/opt/viv_samples/vdk/) . It is in fact possible to run these in a chroot environment - be sure to use mount -o bind to setup /dev /proc etc. and also, permission 660 on /dev/galcore as mentioned previously allows non-root access to device for owning group (video).

xserver-xorg-video-imx-viv provides the Vivante EXA driver as source code - it must be built against the version of X.org release intending to run on the rfs, and in addition depends on Freescsale's version of libraries and system headers from imx-gpu-viv-5.0.11.p7.1-hfp.bin. The following compile line should work and some additional notes may be useful for troubleshooting problems:

./fastbuild.sh  XSERVER_GREATER_THAN_13=1 BUILD_HARD_VFP=1 BUSID_HAS_NUMBER=1

So what could go wrong?

No such file or directory #include "xorg-server.h" ... this is fixed by installing xserver-xorg-dev (installed from local built .deb) ... note this and other references may need to be modified to #include "xorg/xorg-server.h".

One compile problem that may be encountered in  xserver-xorg-video-imx-viv-5.0.11.p7.1.tar.gz is path to drm.h ... easily corrected in EXA/src/makefile.linux i.e. /usr/include/libdrm/drm.h

Previous versions of xserver-xorg-video-imx tended to have many more compile problems when built against newer versions of X.org, e.g. as shown in the notes below in case the information is useful to anybody. In fact any failures building DRI_1.10.4 can probably be ignored, as this is probably by now already provided by X.org server and is no longer distributed with 5.0.11 series (fastbuild may still try to build it and errors out).

gcc -mfpu=vfp -mfloat-abi=hard -fvisibility=hidden -fPIC -DPIC -I. -I.. -I//usr/include -I//usr/include/xorg -I//usr/include/pixman-1 -I../../EXA/src/vivante_gal -march=armv7-a -marm -o dri.o -c dri.c
dri.c:42:18: fatal error: xf86.h: No such file or directory
 #include "xf86.h"
(Also may need to be changed to "xorg/xf86.h")

makefile.linux:71: recipe for target 'dri.o' failed

DRI_1.10.4/src/drm.h
                 from dri.c:52:
./drm.h:620:26: fatal error: drm/drm_mode.h: No such file or directory


If you got through all that then finally, install the driver, configure X.org server:

 cp src/xserver-xorg-video-imx-viv-3.10.31-1.1.0-beta/EXA/src/vivante_drv.so  /usr/lib/xorg/modules/drivers/
 cp Download/sys/xorg.conf  /usr/share/X11/xorg.conf.d/

... and then hopefully enjoy a successful startx moment:
$ grep VIVANTE:  /var/log/Xorg.0.log
[   188.626] (II) VIVANTE: driver for vivante fb: VivanteGC500, VivanteGC2100,
sabrehd@sabresd:~/Downloads$ 


For bonus points, debuild and install mesa-utils and maybe at least one prerequisite:
sudo dpkg -i mesa/libgles2-mesa_10.3.2-1+deb8u1_armhf.deb
sudo dpkg -i mesa-utils/mesa-utils-extra_8.2.0-1_armhf.deb

Enjoy!

Monday, January 26, 2015

glmark and Mesa-demos on i.MX6

Accelerated performance of glmark2 and mesa-demos benchmarks on i.MX6 is dependent upon on ARM specific additions to xf86drm.h and so require a patched and scratched X.org installation, e.g. previous post X.org from Scratch. Note that for control, the builds below are done in an X.org environment which is purposely not exposed to the GPU libraries/headers installation, picking up support from the standard MesaLib presumably installed along with X.org from source. The impact of building the utilities against the Freescale supplied headers and libraries is not evident to me at this time.

Mesa sources may have already been patched to provide a couple of the utilities, the outcome of running without GPU support is as expected:

make -C xdemos install

debian@arm:~$ glxgears -info
GL_RENDERER   = Software Rasterizer
GL_VERSION    = 2.1 Mesa 9.2.0
GL_VENDOR     = Mesa Project

debian@arm:~$ glxinfo
name of display: :0.0
Error: couldn't find RGB GLX visual or fbconfig

$ es2gears_x11  -info
libEGL warning: DRI2: failed to authenticate
EGL_VERSION = 1.4 (DRI2)
EGL_VENDOR = Mesa Project
EGL_EXTENSIONS = EGL_KHR_surfaceless_context
EGL_CLIENT_APIS = OpenGL OpenGL_ES OpenGL_ES2 OpenGL_ES3
vertex shader info:
fragment shader info:
info:
159 frames in 5.0 seconds = 31.699 FPS


mesa-demos-8.2.0
The complete mesa-demos package will provide es2_gears among other things.

wget http://downloads.sourceforge.net/project/glew/glew/1.11.0/glew-1.11.0.tgz

make install GLEW_PREFIX=$PREFIX GLEW_DEST=$PREFIX 

curl -O ftp://ftp.freedesktop.org/pub/mesa/glu/glu-9.0.0.tar.bz2

./configure --prefix=$PREFIX --disable-static && make

wget ftp://ftp.freedesktop.org/pub/mesa/demos/8.2.0/mesa-demos-8.2.0.tar.gz
./configure $XORG_CONFIG && make

Be sure to have the prerequisites installed, otherwise there will be trouble:

mesa-demos reports "Package 'glu', required by 'glew', not found"
glew reports missing "glu-9.0.0" ... install from LFS:

Without GPU, es2gears is pretty un-remarkable, but getting through the build is a sign of good things to come:

~$ es2gears_x11
libEGL warning: DRI2: failed to authenticate
EGL_VERSION = 1.4 (DRI2)
vertex shader info:
fragment shader info:
info:
157 frames in 5.0 seconds = 31.207 FPS


glmark2

apt-get install libjpeg-dev

# Retrieve glmark2 source:
git clone https://github.com/glmark2/glmark2.git

# glmark has it's own configuration utility:
./waf configure --with-flavors=x11-gl,x11-glesv2 # drm-gl,drm-glesv2

# CPLUS_INCLUDE_PATH should already be set in the building shell environment, but must be forced to suppress error on src/libmatrix/program.cc:
CPLUS_INCLUDE_PATH=$PREFIX/include:$CPLUS_INCLUDE_PATH ./waf build -v 


Checking for 'x11'                       : yes
Checking for 'gl'                        : yes
Checking for 'egl'                       : yes
Checking for 'glesv2'                    : yes
Checking for 'libdrm'                    : yes
Checking for 'gbm'                       : yes

If everything has built correctly at this time, check the utilities against the FBDEV (non-GPU) driver, or skip ahead to enable GPU support on the system. 

waf will automatically enable/disable features depending upon the installed Mesa configuration that it detects. I suspect that the Debian Mesa package may not enable gles ... this is what my working configuration ends up looking like:

# Note Mesa-9.2.0 configure line (more detail on Mesa configuration below):
autoreconf -fi &&
./configure CFLAGS="-O2" CXXFLAGS="-O2"    \
            --prefix=$XORG_PREFIX          \
            --sysconfdir=/etc \
            --with-dri-drivers=swrast \
            --disable-gallium-egl --disable-gallium-llvm \
            --disable-gallium-gbm \
            --with-gallium-drivers="" \
           --enable-gles2 \
            --disable-gles1 \
            --enable-gbm  # auto?

# result of Mesa-9.2.0 configuration from above:
        prefix:          /usr/local
        exec_prefix:     ${prefix}
        libdir:          ${exec_prefix}/lib
        includedir:      ${prefix}/include

        OpenGL:          yes (ES1: no ES2: yes)
        OpenVG:          no

        OSMesa:          no
        DRI drivers:     swrast
        DRI driver dir:  ${libdir}/dri
        GLX:             DRI-based

        EGL:             yes
        EGL platforms:   x11
        EGL drivers:     builtin:egl_glx builtin:egl_dri2

        llvm:            no

        Gallium:         no

        Shared libs:     yes
        Static libs:     no
        Shared-glapi:    yes

        CFLAGS:          -O2 -Wall -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes -fno-strict-aliasing -fno-builtin-memcmp
        CXXFLAGS:        -O2 -Wall -fno-strict-aliasing -fno-builtin-memcmp
        Macros:          -D_GNU_SOURCE -DHAVE_PTHREAD -DHAVE_DLOPEN -DHAVE_POSIX_MEMALIGN -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING -DUSE_EXTERNAL_DXTN_LIB=1 -DHAVE_ALIAS -DHAVE_MINCORE -DHAVE_LIBUDEV

        PYTHON2:         python2

        Run 'make' to build Mesa


Without glesv2 enabled:

autoreconf -fi &&
./configure CFLAGS="-O2" CXXFLAGS="-O2"    \
            --prefix=$XORG_PREFIX          \
            --sysconfdir=/etc \
            --with-dri-drivers=swrast \
            --disable-egl --disable-gbm \
            --disable-gallium-egl --disable-gallium-llvm \
            --disable-gallium-gbm \
            --with-gallium-drivers="" \
            --disable-shared-glapi \
            --enable-glx

./waf configure --with-flavors=x11-gl

Should see something like this ...

Checking for 'x11'                       : yes
Checking for 'gl'                        : yes
Checking for 'egl'                       : not found
Checking for 'glesv2'                    : not found
Checking for 'libdrm'                    : yes
Checking for 'gbm'                       : not found

... and glmark2 should work:

    GL_VENDOR:     Mesa Project
    GL_RENDERER:   Software Rasterizer
    GL_VERSION:    2.1 Mesa 9.2.0


Mesa must be configured with egl/gles in order for glmark-es2 to build:

 ./waf configure --with-flavors=x11-gl,x11-glesv2
Checking for 'x11'                       : yes
Checking for 'gl'                        : yes
Checking for 'egl'                       : yes
Checking for 'glesv2'                    : not found

# "--with-egl-platforms=x11,drm" automatically enabled?

autoreconf -fi &&
./configure CFLAGS="-O2" CXXFLAGS="-O2"    \
            --prefix=$XORG_PREFIX          \
            --sysconfdir=/etc \
            --with-dri-drivers=swrast \
            --disable-gbm \
            --disable-gallium-egl --disable-gallium-llvm \
            --disable-gallium-gbm \
            --with-gallium-drivers="" \
            --disable-shared-glapi \
           --enable-gles2  --enable-egl

        OpenGL:          yes (ES1: no ES2: yes)
        OpenVG:          no

        OSMesa:          no
        DRI drivers:     swrast
        DRI driver dir:  ${libdir}/dri
        GLX:             DRI-based

        EGL:             yes
        EGL platforms:   x11
        EGL drivers:     builtin:egl_glx builtin:egl_dri2

Should now have libGLESv2.so.2:

Checking for 'x11'                       : yes
Checking for 'gl'                        : yes
Checking for 'egl'                       : yes
Checking for 'glesv2'                    : yes
Checking for 'libdrm'                    : yes


glapi is also required:

/opt/xorg/lib/libGLESv2.so: undefined reference to `_glapi_get_dispatch'
/opt/xorg/lib/libGLESv2.so: undefined reference to `_glapi_Dispatch'

autoreconf -fi &&
./configure CFLAGS="-O2" CXXFLAGS="-O2"    \
            --prefix=$XORG_PREFIX          \
            --sysconfdir=/etc \
            --with-dri-drivers=swrast \
            --disable-gbm \
            --disable-gallium-egl --disable-gallium-llvm \
            --disable-gallium-gbm \
            --with-gallium-drivers="" \
           --enable-gles2
#            --disable-shared-glapi

        Shared-glapi:    yes


~$ glmark2
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
=======================================================
    glmark2 2014.03
=======================================================
    OpenGL Information
    GL_VENDOR:     Mesa Project
    GL_RENDERER:   Software Rasterizer
    GL_VERSION:    2.1 Mesa 9.2.0
=======================================================
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
[build] use-vbo=false: FPS: 4 FrameTime: 250.000 ms


glmark2-es2 runs but has other complaints and performs poorly (as expected):

~$ glmark2-es2
libEGL warning: DRI2: failed to authenticate
=======================================================
    glmark2 2014.03
=======================================================
    OpenGL Information
    GL_VENDOR:     Mesa Project
    GL_RENDERER:   Software Rasterizer
    GL_VERSION:    OpenGL ES 2.0 Mesa 9.2.4
=======================================================
[build] use-vbo=false: FPS: 5 FrameTime: 200.000 ms


Mesa must be configured with "--enable-gbm" in order to get glmark-drm and glmark-es2-drm built.



Enabling GPU acceleration

The GPU-laced headers have to be in place for the Vivante EXA driver to build from source ... detailed steps are provided in this post. Some additional notes are below.

With the GPU blobs and headers installed to /usr, it's pretty likely to have overlaps with MesaLib installed to the X.org root, e.g.:

debian@arm:~/gpu-viv-bin-mx6q-3.10.17-1.0.2-hfp/usr$  for f in `find`; do [ -f $f ] && find /usr/local -name `echo $f | sed 's/.*\///'`  ; done
/usr/local/lib/libEGL.so
/usr/local/lib/libGLESv2.so
/usr/local/lib/libGLESv2.so.2
/usr/local/lib/libGLESv2.so.2.0.0
/usr/local/lib/libGL.so
/usr/local/lib/libEGL.so.1
/usr/local/lib/libGL.so.1
/usr/local/include/EGL/eglplatform.h
/usr/local/include/EGL/eglext.h
/usr/local/include/EGL/egl.h
/usr/local/include/GLES2/gl2platform.h
/usr/local/include/GLES2/gl2.h
/usr/local/include/GLES2/gl2ext.h
/usr/local/include/KHR/khrplatform.h
/usr/local/include/GL/gl.h
/usr/local/include/EGL/egl.h
/usr/local/include/GL/glext.h

At a minimum, removing the following symlinks should allow the blob versions to get priority:


# With the GPU enabled blobs installed, the stock ones from installed Mesa need to be disabled from the X.org runtime environment (and again pretty much anytime ldconfig gets run on the system):
 cd $PREFIX/lib

 sudo rm libGL.so libGL.so.1 libGLESv2.so libGLESv2.so.2 libEGL.so libEGL.so.1 libGL.so.1
ldd glmark-es2 # etc. etc.

Before trying out X.org, it should be possible to run the frame-buffer benchmarks in opt/viv_samples/vdk/.

Finally, getting to the EXA driver:

~/Download/xserver-xorg-video-imx-viv-3.10.17-1.0.2
BUILD_HARD_VFP=1 XSERVER_GREATER_THAN_13=1 BUSID_HAS_NUMBER=1 ./fastbuild.sh sysroot=/usr/local # specify sysroot if not /usr

Depending upon the specific "$PREFIX" used for X.org, it may be necessary to patch up some include paths in EXA/src/makefile.linux, FslExt/src/makefile.linux, and util/autohdmi/makefile.linux e.g.:

~xserver-xorg-video-imx-viv-3.10.17-1.0.2$
 for f in `find . -name makefile.linux`; do  sed -e 's/(sysroot)\/usr/(sysroot)/g' -i $f; done

 sed -e 's/\/drm/\/libdrm/' -i EXA/src/makefile.linux

# with pixman-1 installed from dpkg:





/usr/local/include/xorg/miscstruct.h:52:20: fatal error: pixman.h: No such file or directory


# fixup path to /usr/include/pixman-1/pixman.h in makefile


 -I$(sysroot)/include/$(PIXMAN)


# Finally ...

sudo cp EXA/src/vivante_drv.so  $PREFIX/lib/xorg/modules/drivers/


# don't forget to enable Vivante
setup /etc/X11/xorg.conf


# relink libraries for x11
switch_to_x11



:~$ LIBGL_DEBUG=verbose glxgears  -info
libGL: OpenDriver: trying /usr/lib/dri/vivante_dri.so
drmOpenByBusid: Searching for BusID platform:Vivante GCCore:00
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 4, (OK)
drmOpenByBusid: drmOpenMinor returns 4
drmOpenByBusid: drmGetBusid reports platform:Vivante GCCore:00
GL_RENDERER   = Vivante GC2000
GL_VERSION    = 2.1 2.0.1
GL_VENDOR     = Vivante Corporation
GL_EXTENSIONS = WGL_ARB_extensions_string WGL_EXT_extensions_string WGL_EXT_swap
_control GL_EXT_texture_env_add GL_ARB_multitexture GL_ARB_multisample GL_ARB_te
... ...
ltisample GL_EXT_texture_array GL_EXT_draw_buffers2 GL_EXT_texture_buffer_object
 GL_EXT_draw_instanced GL_EXT_timer_query
VisualID 184, 0xb8
912 frames in 5.0 seconds = 182.398 FPS


~$ LIBGL_DEBUG=verbose es2gears_x11  -info
drmOpenByBusid: Searching for BusID platform:Vivante GCCore:00
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 5, (OK)
drmOpenByBusid: drmOpenMinor returns 5
drmOpenByBusid: drmGetBusid reports platform:Vivante GCCore:00
EGL_VERSION = 1.4
EGL_VENDOR = Vivante Corporation
EGL_EXTENSIONS = EGL_KHR_reusable_sync EGL_KHR_fence_sync EGL_KHR_image EGL_KHR_
image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_c
ubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_lock_surface
EGL_CLIENT_APIS = OpenGL_ES OpenVG
vertex shader info:
fragment shader info:
info:
853 frames in 5.0 seconds = 170.566 FPS


~$ LIBGL_DEBUG=verbose glmark2-es2
drmOpenByBusid: Searching for BusID platform:Vivante GCCore:00
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 5, (OK)
drmOpenByBusid: drmOpenMinor returns 5
drmOpenByBusid: drmGetBusid reports platform:Vivante GCCore:00
=======================================================
    glmark2 2014.03
=======================================================
    OpenGL Information
    GL_VENDOR:     Vivante Corporation
    GL_RENDERER:   Vivante GC2000
    GL_VERSION:    OpenGL ES 2.0
=======================================================
[build] use-vbo=false: FPS: 396 FrameTime: 2.525 ms



These errors were seen at some point but IDNR what configuration:

debian@arm:~$ glmark2-es2
=======================================================
    glmark2 2014.03
=======================================================
    OpenGL Information
    GL_VENDOR:     Vivante Corporation
    GL_RENDERER:   Vivante GC2000
    GL_VERSION:    OpenGL ES 2.0
=======================================================
[build] use-vbo=false:
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 253 FrameTime: 3.953 ms
=======================================================
                                  glmark2 Score: 252
=======================================================
[xcb] Unknown sequence number while appending request
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
glmark2-es2: ../../src/xcb_io.c:161: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed.
Aborted
~$


Latest results running on 3.10.31 series, the update to "OpenGL ES 3.0" is seen.

debian@arm:~$ !473
LIBGL_DEBUG=verbose glmark2-es2
drmOpenByBusid: Searching for BusID platform:Vivante GCCore:00
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 5, (OK)
drmOpenByBusid: drmOpenMinor returns 5
drmOpenByBusid: drmGetBusid reports platform:Vivante GCCore:00
=======================================================
    glmark2 2014.03
=======================================================
    OpenGL Information
    GL_VENDOR:     Vivante Corporation
    GL_RENDERER:   Vivante GC2000
    GL_VERSION:    OpenGL ES 3.0 V5.0.11.p1.19959
=======================================================
[build] use-vbo=false: FPS: 399 FrameTime: 2.506 ms
[build] use-vbo=true:^C

glxgears slower?
debian@arm:~$ LIBGL_DEBUG=verbose glxgears -info
libGL: OpenDriver: trying /usr/lib/dri/vivante_dri.so
drmOpenByBusid: Searching for BusID platform:Vivante GCCore:00
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 4, (OK)
drmOpenByBusid: drmOpenMinor returns 4
drmOpenByBusid: drmGetBusid reports platform:Vivante GCCore:00
GL_RENDERER   = Vivante GC2000
GL_VERSION    = 2.1 2.0.1
GL_VENDOR     = Vivante Corporation
GL_EXTENSIONS = WGL_ARB_extensions_string WGL_EXT_extensions_string WGL_EXT_swap_control GL_EXT_texture_env_add GL_ARB_multitexture GL_ARB_multisample GL_ARB_texture_env_add GL_ARB_texture_compression GL_ARB_texture_env_combine GL_ARB_depth_texture GL_ARB_window_pos GL_ARB_vertex_buffer_object GL_ARB_imaging GL_EXT_framebuffer_object GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_texture_array GL_EXT_draw_buffers2 GL_EXT_texture_buffer_object GL_EXT_draw_instanced GL_EXT_timer_query
VisualID 191, 0xbf
757 frames in 5.0 seconds = 151.342 FPS
742 frames in 5.0 seconds = 148.313 FPS
^CProcess termination by interupt!