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!

Thursday, January 22, 2015

X.Org X Server 1.14.5, Debian, i.MX6

Previously I had some success getting the GPU to work on i.MX6 by building X.org from scratch over a Debian armhf deboostrap installation. Nice learning exercise but a little labor intensive. My previous attempt at setting up on Ubuntu with Xorg 1.14.6 (no sources, just dpkg) works at least partially - glxgears and es2gears_x11 run smoothly using the GPU.  

As far as I know X.org 1.15 or later won't work (GPU blobs from 3.10.17-1.0.2 BSP release) ... based on the comment I saw over on Tiny Devices. Thanks to athmsVT, I found out about snapshot.debian.org, which makes it easy to get a debootstrap install that contains "xserver-xorg-core 2:1.14.5-1". The snapshot I am using is precisely the last one prior to adding xserver-xorg-core_1.15:
http://snapshot.debian.org/archive/debian/20140106T095748Z/pool/main/x/xorg-server/

Here goes ...

# debootstrap rootfs to partition on SD card
sudo mkfs.ext4 /dev/sda1

# mounting the freshly-mkfs'd partion:
sudo mount /dev/sda1 /media/rootfs 

# for a non-snapshot install, the following can be used:
sudo debootstrap --arch=armhf jessie /media/rootfs/ \
http://ftp.us.debian.org/debian/

# if host is also armhf system, probably don't need to specify '--foreign' or '--arch' arguments:
sudo debootstrap --arch=armhf jessie /media/rootfs/ \
http://snapshot.debian.org/archive/debian/20140106T095748Z/

sudo chroot /media/rootfs/

# in debootstrap'd rootfs
export LANG=C

# can ignore the "--second-stage" if not building an install for a foreign architecture
# /debootstrap/debootstrap --second-stage

cat /etc/apt/sources.list # main repo already setup in sources.list, e.g.

deb http://snapshot.debian.org/archive/debian/20131213T220007Z jessie main


# suppress "InRelease is expired " warnings if installing from a snapshot
apt-get -o Acquire::Check-Valid-Until=false update  

apt-get install locales dialog ntpdate

# in chroot, this error can be ignored for now ...

E: Can not write log (Is /dev/pts mounted?) - openpty (2: No such file or directory)

# ... but should be configured if continuing to work in chroot, e.g.:

# prior to entering chroot environment ...
sudo mkdir /media/rootfs/run/udev # if not exist

$ cat chroot_env.sh

rootfs=/opt/rootfs
mount -o bind /proc $rootfs/proc
mount -o bind /dev $rootfs/dev
mount -o bind /dev/pts $rootfs/dev/pts
mount -o bind /sys $rootfs/sys
mount -o bind /run/udev $rootfs/run/udev

dpkg-reconfigure locales # en_US.UTF-8 UTF-8


# user must be in group video for galcore access
adduser debian

usermod -a -G video debian

# while you're at it, set a password for root ... 
passwd

# setup serial console in /etc/inittab ... the inittab is otherwise incomplete in 
VERSION="8 (jessie)"
T1:23:respawn:/sbin/getty -L ttymxc1 115200 vt102

# home on separate partition in /etc/fstab (note, depending upon the kernel used, the exact name of the mmcblk device may vary):

/dev/mmcblk0p1   /           auto   errors=remount-ro   0   1
/dev/mmcblk0p2   /home       auto   defaults            0   2


# /etc/network/interface:

auto lo
iface lo inet loopback

auto eth0

iface eth0 inet dhcp

allow-hotplug wlan0

iface wlan0 inet manual
  wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp


#Enable drm, vivante in kernel (
CONFIG_DRM_VIVANTE=m, CONFIG_DRM=m)
echo "vivante" >> /media/rootfs/etc/modules

#Install kernel, modules, firmware in the usual way.
# Make note of comments regarding CONFIG_FHANDLE in my previous post.

sudo make firmware_install INSTALL_FW_PATH=/media/rootfs/lib/firmware

sudo umount /media/rootfs/  

# and reboot ...

# u-boot args for 3.10.17 which need to be saved to flash:

setenv bootargs console=${console},${baudrate} root=/dev/mmcblk0p1  rootfstype=ext4 rootwait video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off video=mxcfb4:off video=mxcfb5:off video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB16 fbmem=48M vmalloc=400 mxc_hdmi.only_cea=1 coherent_pool=48M

ext2load mmc ${mmcdev}:${mmcpart} ${fdt_addr} boot/${fdt_file}

ext2load mmc ${mmcdev}:${mmcpart} ${loadaddr} boot/${image}
bootz ${loadaddr} - ${fdt_addr}



Did it work?

apt-get install sudo ssh

If you want go it from scratch, follow this post.

Onward ...

# confirm versions


root@debian-imx6:/home# apt-cache show xserver-xorg-core
Package: xserver-xorg-core
Source: xorg-server

Version: 2:1.14.5-1

root@debian-imx6:/home# apt-cache show libpixman-1-0
Package: libpixman-1-0
Source: pixman

Version: 0.32.4-1


apt-get install --no-install-recommends xserver-xorg-input-all xserver-xorg-video-fbdev xserver-xorg xinit

apt-get install --no-install-recommends mesa-utils mesa-utils-extra
apt-get install --no-install-recommends xserver-xorg-dev libxext-dev 


curl -O http://downloads.yoctoproject.org/mirror/sources/xserver-xorg-video-imx-viv-3.10.17-1.0.0.tar.gz
curl -O http://downloads.yoctoproject.org/mirror/sources/gpu-viv-bin-mx6q-3.10.17-1.0.0-hfp.bin



:~/gpu-viv-bin-mx6q-3.10.17-1.0.2-hfp/usr$ for f in `find`; do [ -f $f ] && find /usr -name `echo $f | sed 's/.*\///'`  ; done
/usr/include/GL/gl.h       # include/GLES2/gl2.h
/usr/include/GL/glext.h  # include/GLES/glext.h

/usr/lib/arm-linux-gnueabihf/mesa/libGL.so.1




$ dpkg -S libGL.so.1

libgl1-mesa-glx:armhf: /usr/lib/arm-linux-gnueabihf/libGL.so.1

libgl1-mesa-glx:armhf: /usr/lib/arm-linux-gnueabihf/libGL.so.1.2.0


glext.h: mesa-common-dev ... these will come from blobs ... include/GLES


debian@debian-imx6:~$ ls -l /dev/dri/card0
crw-rw---- 1 root video 226, 0 Jan 21 23:00 /dev/dri/card0
debian@debian-imx6:~$ ls -l /dev/galcore
crw------- 1 root root 199, 0 Jan 21 23:00 /dev/galcore

Segmentation fault on tutorial7


https://raw.githubusercontent.com/Freescale/meta-fsl-arm/master/recipes-core/udev/udev-rules-imx/10-imx.rules

#KERNEL=="mxc_galcore", MODE="0666"  # GN: device doesn't exist with my kernel
KERNEL=="mxc_asrc",  MODE="0666"


# should have proper permissions now (tutorial7 will segfault otherwise):
debian@debian-imx6:~$ ls -l /dev/galcore
crw-rw---- 1 root video 199, 0 Jan 22 00:37 /dev/galcore


# On Debian, the following symlinks should be removed:
# from libegl1-mesa
/usr/lib/arm-linux-gnueabihf/libEGL.so.1 \
/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 
# from libgles2-mesa
/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2 \
/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0

Exit X if it is running, verify something in viv_samples/vdk works correctly in framebuffer.


apt-get install xserver-xorg-dev, libxext-dev

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

/usr/include/libdrm/drm.h # fixup path on snapshot Jessie

#EXA/src/makefile.linux:
#LOCAL_CFLAGS += -I$(sysroot)/usr/include/drm
# change to:
LOCAL_CFLAGS +=  -I$(sysroot)/usr/include/libdrm

cp EXA/src/vivante_drv.so /usr/lib/xorg/modules/drivers


https://raw.githubusercontent.com/Freescale/meta-fsl-arm/master/recipes-graphics/xorg-xserver/xserver-xf86-config/mx6/xorg.conf

# verify if the following is actually needed in xorg.conf:
Section "dri"
  Mode 0666
EndSection

## fire it up and expect the following:


glxgears, es2gears, glmark2-es2 should run in ssh session as non-root.
glmark2 probably a no-show, apparently needs standard libGL or libGAL ... not from package, must have been scratchbuilt
es2tri: should work but hangs X
imx6:~$ es2gears_screen  
EGL_VERSION = 1.4
EGLUT: failed to choose a config


# Debian ... TODO replicate this issue - can't remember what it was (mxc_galcore / udev'd ??)


LIBGL_DEBUG=verbose glxgears


libGL: OpenDriver: trying /usr/lib/dri/vivante_dri.so
drmOpenByBusid: Searching for BusID platform:Vivante GCCore
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 4, (OK)
drmOpenByBusid: drmOpenMinor returns 4
drmOpenByBusid: drmGetBusid reports platform:Vivante GCCore:00
drmOpenDevice: node name is /dev/dri/card1
drmOpenByBusid: drmOpenMinor returns -1003



# be careful of where dpkg has installed Mesa, 
# e.g. /usr/lib/arm-linux-gnueabihf/, /usr/lib/arm-linux-gnueabihf/-mesa

# check dependencies with ldd:
# glmark2, glxgears -> libGL-> libGAL 
# glmark2-es2, es2gears -> libEGL -> libGAL; libGLESv2 -> libGAL, libEGL

# example of wrong libGL being found:
debian@debian-imx6:~$ LIBGL_DEBUG=verbose glxgears
libGL: screen 0 does not appear to be DRI2 capable
libGL: XF86DRIGetClientDriverName: 4.1.0 vivante (screen 0)
libGL: OpenDriver: trying /usr/lib/arm-linux-gnueabihf/dri/tls/vivante_dri.so
libGL: OpenDriver: trying /usr/lib/arm-linux-gnueabihf/dri/vivante_dri.so
libGL error: dlopen /usr/lib/arm-linux-gnueabihf/dri/vivante_dri.so failed (/usr
/lib/arm-linux-gnueabihf/dri/vivante_dri.so: cannot open shared object file: No
such file or directory)
libGL: OpenDriver: trying ${ORIGIN}/dri/tls/vivante_dri.so
libGL: OpenDriver: trying ${ORIGIN}/dri/vivante_dri.so
libGL error: dlopen ${ORIGIN}/dri/vivante_dri.so failed (${ORIGIN}/dri/vivante_d
ri.so: cannot open shared object file: No such file or directory)
libGL: OpenDriver: trying /usr/lib/dri/tls/vivante_dri.so
libGL: OpenDriver: trying /usr/lib/dri/vivante_dri.so
libGL error: driver exports no extensions (/usr/lib/dri/vivante_dri.so: undefine
d symbol: __driDriverExtensions)
libGL error: failed to load driver: vivante
libGL: OpenDriver: trying /usr/lib/arm-linux-gnueabihf/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/arm-linux-gnueabihf/dri/swrast_dri.so

~$ ldd /usr/bin/glxgears  | grep 'libGL\.'
        libGL.so.1 => /usr/lib/arm-linux-gnueabihf/libGL.so.1 (0
rm /usr/lib/arm-linux-gnueabihf/libGL.so.1
~$ ldd /usr/bin/glxgears  | grep 'libGL\.'
        libGL.so.1 => /usr/lib/libGL.so.1 (0x76e78000)


# also need to be vigilant following some installs with links being re-created in /usr/lib/arm-linux-gnueabihf/:


debian@debian-imx6:~$ ldd /usr/bin/es2gears

        libGLESv2.so.2 => /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2 (0x76f39000)
        libEGL.so.1 => /usr/lib/arm-linux-gnueabihf/libEGL.so.1 (0x76db5000)
rm /usr/lib/arm-linux-gnueabihf/libEGL.so.1

# es2gears runs happily, but blank window:
rm /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2


# Finally ... should see something like this:

~$ LIBGL_DEBUG=verbose es2gears -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:
813 frames in 5.0 seconds = 162.503 FPS
811 frames in 5.0 seconds = 162.168 FPS


# and 

debian@debian-imx6:~$ glxinfo
name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap,
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer,
    GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
    GLX_SGIX_pbuffer, GLX_SGI_make_current_read
client glx vendor string: Vivante Corp
client glx version string: 1.4


# libjpeg8


glxgears # will run in software if libGL is /usr/lib/arm-linux-gnueabihf/libGL.so.1


libGL error: failed to load driver: vivante

rm /usr/lib/arm-linux-gnueabihf/libGL.so.1


#  ... but ... glmark-es2 runs but no window then X is hosed
debian@debian-imx6:~$ 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 2012.08
=======================================================
    OpenGL Information
    GL_VENDOR:     Vivante Corporation
    GL_RENDERER:   Vivante GC2000
    GL_VERSION:    OpenGL ES 2.0
=======================================================



### what about ubuntu (13.10, Xorg 1.14.6)?

ubuntu@arm:/etc/X11$ LIBGL_DEBUG=verbose es2gears -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_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_lock_surface
EGL_CLIENT_APIS = OpenGL_ES OpenVG
EGLUT: failed to create context