shaurz
Posts: 49
Joined: Thu Nov 03, 2011 12:09 pm

Re: Compiling and running OpenGL ES programs

Thu May 10, 2012 10:39 pm

I want to try compiling and running some OpenGL test programs. I'm using the Arch Linux image.

It seems that the Raspberry Pi specific libraries are located in /opt/vc/lib instead of /usr/lib. This presents a bit of a problem since project makefiles need to be modified to point to this directory, but nothing that can't be overcome. It would be nice to see them in the regular locations but I guess this is still very much work in progress.

I have managed to compile glmark2-es and run it using LD_LIBRARY_PATH=/opt/vc/lib, but the program fails due to eglGetDisplay() returning error code 12288 (whatever that means).

Anything I'm doing wrong? What is the status of GLES support (does anything work at the moment)?

shirro
Posts: 248
Joined: Tue Jan 24, 2012 4:54 am

Re: Compiling and running OpenGL ES programs

Thu May 10, 2012 10:51 pm

Look at the demo code in /opt/vc/src/hello_pi/hello_triangle. You need to modify your program to use bcm_init() then add an element to dispmanx, then pass it in a struct as nativewindow to glCreateWindowSurface.

https://github.com/peterderivaz/pyopeng ... pengles.py does the same thing and although it is in Python it matches what you would do in c.

In Debian the path is in a file in /opt/vc/lib is in /etc/ld.so.d. Since you are on Arch you might just want to add it to /etc/ld.so.conf

In Debian usually only packaged programs would go in /usr so it is appropriate for the vc stuff to be in opt. I would like to see that changed when it gets packaged as well. Meanwhile changing some CFLAGS and LDFLAGS is no big deal.

shaurz
Posts: 49
Joined: Thu Nov 03, 2011 12:09 pm

Re: Compiling and running OpenGL ES programs

Fri May 11, 2012 12:40 am

Thanks for the info. I managed to get the triangle demo working (but it was missing -lpthread in the Makefile).

I've been hacking away at glmark2-es and made a bit of progress. eglGetDisplay() now works, but only when given EGL_DEFAULT_DISPLAY instead of the X Display pointer.

The current stumbling block is that XGetVisualInfo is failing when using the visual ID returned from eglGetConfigAttrib(..., EGL_NATIVE_VISUAL_ID, ...).

shaurz
Posts: 49
Joined: Thu Nov 03, 2011 12:09 pm

Re: Compiling and running OpenGL ES programs

Fri May 11, 2012 7:39 am

It has just dawned on me that these drivers don't have any integration with X yet, do they? That would explain these problems. Guess I'll have to gut out all the X stuff and make it work with the framebuffer only.

gregd72002
Posts: 31
Joined: Tue May 08, 2012 9:17 pm

Re: Compiling and running OpenGL ES programs

Sat May 12, 2012 10:03 pm

This should not be too difficult... Neither (I think) you need any X11 drivers/knowledge. I'm on a 'similar' boat to you trying to get this working. Looking at the sources the canvas*.cpp files must be ported to RPi; or preferably - a RPi version of them to be written.

Meantime, I created a patch to glmark2 to start the work: http://pastebin.com/JghW8tXQ

What it does:
- adds new configuration option to build for RPi: --enable-rpi
- fixes issues with newer version of libpng

Once glmark2 is configured using --enable-rpi option the compilation process will use 'canvas-rpi.cpp' file which is to be written. This option also removes x11 dependency.

Hope this helps. Waiting for some progress!

PS. as mentioned in earlier posts hello_triangle program provides all information on EGL initialization on RPi. Thus, the next step is:
- analyse canvas-x11.cpp and canvas-x11-egl.cpp to understand how currently glamark2 initialize graphics
- write 'canvas-rpi.cpp' using code from hello_triangle
Attachments
glmark2-rpi.zip
(1.77 KiB) Downloaded 353 times

benosteen
Posts: 28
Joined: Mon Jan 02, 2012 6:10 am

Re: Compiling and running OpenGL ES programs

Sun May 13, 2012 9:54 am

In case it helps others, I've tried to lay out all the main changes you need to do to display an OpenGL ES surface on the RPi without using X windows here http://benosteen.wordpress.com/2012/04/ ... x-windows/

shaurz
Posts: 49
Joined: Thu Nov 03, 2011 12:09 pm

Re: Compiling and running OpenGL ES programs

Sun May 13, 2012 11:53 am

I managed to port it to the Raspberry Pi, some of the tests work and some don't.

Video: http://www.youtube.com/watch?v=9zZeXK3yVF4
Source: https://github.com/shaurz/rpi/tree/master/glmark2

Narishma
Posts: 151
Joined: Wed Nov 23, 2011 1:29 pm

Re: Compiling and running OpenGL ES programs

Sun May 13, 2012 6:41 pm

shaurz wrote:I managed to port it to the Raspberry Pi, some of the tests work and some don't.

Video: http://www.youtube.com/watch?v=9zZeXK3yVF4
Source: https://github.com/shaurz/rpi/tree/master/glmark2
I noticed that most if not all of those tests that appear to fail involve texturing. Can you check that the textures are actually being loaded?

gregd72002
Posts: 31
Joined: Tue May 08, 2012 9:17 pm

Re: Compiling and running OpenGL ES programs

Sun May 13, 2012 8:14 pm

shaurz, do you work still on X11 version or a direct FB (framebuffer but not facebook ;) ) version?

I got my FB version of glmark2 pretty much complete. It configures, compiles and runs fine without any additional LD loaders on archlinux. Also the absolute minimum in terms of dependencies is required. The only problem is that it does something wrong after GPU initialization and it segfaults after rendering thus is needs some more contribution. I'm wondering if we could combine the two versions? This would create a really good performance test of X11 vs direct FB.

Enclosed updated patch. I hope to submit this patch to https://launchpad.net/glmark2 once it is flawlessly working.
Attachments
glmark2-rpi-v2.zip
(4.9 KiB) Downloaded 375 times

gregd72002
Posts: 31
Joined: Tue May 08, 2012 9:17 pm

Re: Compiling and running OpenGL ES programs

Sun May 13, 2012 9:55 pm

shaurz, it looks like you are on the right track. I combined your EGL initiation code (canvas-egl) into my glmark2 build and I got it running. Here are the results:

Code: Select all

=======================================================
    glmark2 2012.03
=======================================================
    OpenGL Information
    GL_VENDOR:     Broadcom
    GL_RENDERER:   VideoCore IV HW
    GL_VERSION:    OpenGL ES 2.0
=======================================================
[build] use-vbo=false: FPS: 75
[build] use-vbo=true: FPS: 179
[texture] texture-filter=nearest: FPS: 232
[texture] texture-filter=linear: FPS: 232
[texture] texture-filter=mipmap: FPS: 232
[shading] shading=gouraud: FPS: 152
[shading] shading=blinn-phong-inf: FPS: 152
[shading] shading=phong: FPS: 148
[bump] bump-render=high-poly: FPS: 116
[bump] bump-render=normals: FPS: 228
[bump] bump-render=height: FPS: 228
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 137
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 80
[pulsar] light=false:quads=5:texture=false: FPS: 230
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 41
[desktop] effect=shadow:windows=4: FPS: 93
Error: Requested MapBuffer VBO update method but GL_OES_mapbuffer is not supported!
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 0
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 10
Error: Requested MapBuffer VBO update method but GL_OES_mapbuffer is not supported!
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 0
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 225
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 227
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 224
[function] fragment-complexity=low:fragment-steps=5: FPS: 228
[function] fragment-complexity=medium:fragment-steps=5: FPS: 228
Error: Failed to link program created from files None and None:  ERROR:OPTIMIZER-3 (line 16) Support for for loops is restricted : right side of condition expression must be constant
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 0
Error: Failed to link program created from files None and None:  ERROR:OPTIMIZER-3 (line 16) Support for for loops is restricted : right side of condition expression must be constant
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 0
Error: Failed to link program created from files None and None:  ERROR:OPTIMIZER-3 (line 16) Support for for loops is restricted : right side of condition expression must be constant
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 0
=======================================================
                                  glmark2 Score: 136
=======================================================

Return to “Other projects”