![]() |
Xlib+OpenGLES performace
Hi.
I have played around with getting a simple GLES app running on my N900 last weekend through the combination of Xlib and EGL, and I got it running ok, although only using an ugly hack. The thing is, if I simply render as fast as I can, I am rendering about 30 frames per second, of which only 10 or so actually end up being displayed. My assumption is that the window manager simply doesn't get enough time on the GPU to display all my rendered frames. I was able to improve this situation by putting a usleep() into my mainloop, but that is hardly a satisfying solution. Does anyone have any pointers on how to wait for the window manager to catch up more cleanly? (I had some hope for eglWaitNative(), but it didn't seem to help when I tried it.) (For those interested, the source can be found at http://exoticorn.de/simplegl.tgz) Another question comes up when comparing the output of 'top' when running my test app to the output when running bounce: While my app is running, I get about 10% CPU usage from Xorg and 4% from hildon-desktop (even in fullscreen mode), while bounce is running, I only see about 4% Xorg and no hildon-desktop at all. Could this mean that bounce is somehow bypassing the window manager (at least in fullscreen mode) and rendering to the screen directly? Any chance of getting some information on how to do this myself? As soon as I can get the basics figured out, I would like to port my game 'spidr' (http://pouet.net/prod.php?which=53019) to the N900. Cheers, Dennis |
Re: Xlib+OpenGLES performace
Quote:
http://lists.maemo.org/pipermail/mae...ch/018645.html Unfortunately I have not seen any public information about the issue, but I would look at the XAtoms of the Bounce's game window. |
Re: Xlib+OpenGLES performace
Hi, I don't know too much about this! :D But after a quick look at the code, just wondering why you're calling XGetWindowAttributes() inside your render function? I'd have assumed it's better to do this in setup or when you get some notification event? (Asking as much for my benefit as for yours ;) )
|
Re: Xlib+OpenGLES performace
@hhedberg:
Thanks, I will look into that as soon as I get a chance. If I find something that works along those lines, it might make the first question obsolete, although I'd still like to find an answer for that for when I'm not running fullscreen. @kwotski: You are right, in a real application you would probably just read out the window size when you get a resize event, but I consider this test app as just a hacky playground to learn about Xlib and EGL, both of which I haven't used before. |
Re: Xlib+OpenGLES performace
exoticorn: Right, but have you tried doing this once in main() instead, and the glViewport(), etc., to see if this is the source of your performance hit?
(or if you want to stay hacky ;) just leave them where they are, but put them in something like: ) Code:
static int donesetup=0; |
Re: Xlib+OpenGLES performace
@kwotski:
No, I haven't tried it, but will do that at the next opportunity. I doubt that this is the cause of the problem, though, as my problem is not CPU related (my app uses about 1.5% CPU time) and in fact the problem is that I am rendering too fast and not too slowly. Btw: While mose GL tutorials tell you to call glViewport in the resize event handler, you can be pretty sure (as long as the GL(ES) implementation isn't completely broken) that a glViewport call per frame isn't the cause for any performance issues. In fact, there are very valid reasons to call glViewport multiple times per frame - think of split screen games or rendering to textures. |
Re: Xlib+OpenGLES performace
See, I learned something ;)
|
Re: Xlib+OpenGLES performace
Quote:
|
Re: Xlib+OpenGLES performace
Quote:
With that and the above I get around 43fps. |
Re: Xlib+OpenGLES performace
@javispedro: Aha! That looks just like what I was hoping for, thanks!
And you are right about the roundtrip time, of course - I didn't give much thought to that as I felt I had some bigger problem to solve first. |
Re: Xlib+OpenGLES performace
Yes, in Bounce we use _HILDON_NON_COMPOSITED_WINDOW. This should bring clear&swap performance up to at least 80 fps.
There is no need to resort to any trickery like sleeping or flushing to gain performance, they will only make things slower. The fewer you bother EGL/GLES the better. Notice also that the rendering is asynchronous if you don't do anything that forces synchronization. This means that the application doesn't have to wait rendering to complete before starting the next one which allows CPU and GPU to work concurrently. |
Re: Xlib+OpenGLES performace
Thanks, Miika, it's good to hear that _HILDON_NON_COMPOSITED_WINDOW is all you need and that no further black magic is required.
I have now tried it and I'm very happy with the results, so all is now set for some game programming over the Xmas holiday. |
Re: Xlib+OpenGLES performace
Hello,
Would you be able to post the new source code for your simple example? I've tried modifying your simplegl code with _HILDON_NON_COMPOSITED_WINDOW and I'm getting about 30 FPS. Shouldn't it be faster? Thanks! |
Re: Xlib+OpenGLES performace
So my first on hand experience and gut feeling was correct whats' going on....
http://talk.maemo.org/showpost.php?p...&postcount=412 :D |
Re: Xlib+OpenGLES performace
Quote:
And please put this into extras-devel so people easily find it, can easily test it and most important are only one tiny "apt-get source" step away from the complete source code and all dependencies they need to compile it themselves. |
Re: Xlib+OpenGLES performace
Quote:
Looking at the version of my code you posted at http://wiki.maemo.org/SimpleGL_Example, I see that you still have the 'usleep(1000*30)' in there, which I guess is the cause for your 30 fps. You also set _NET_WM_STATE_FULLSCREEN twice. Good luck with your game. |
Re: Xlib+OpenGLES performace
Quote:
Cheers. |
Re: Xlib+OpenGLES performace
Hi,
I'm currently learning openGL ES 2.0. I was studying that nice example. Thnks for that. I was reorganizing and commenting it a bit in order to be more understandable. I would like to replace the wiki-example with my version, which you can find here: http://www.agnld.uni-potsdam.de/~ber...gl-example.cpp Is that ok? |
Re: Xlib+OpenGLES performace
Quote:
|
Re: Xlib+OpenGLES performace
Ok, I updated the example program and added a screen shot.
I commented the code, cleaned it up (removing useless includes...) and corrected some small mistakes. I also changed a bit what it's doing, to be a little bit more attractive (watch the screen shot). |
Re: Xlib+OpenGLES performace
BTW, you no longer need the HILDON_NON_COMPOSITED stuff.
|
Re: Xlib+OpenGLES performace
I managed to get keyboard working in your example :)
you need to change: Code:
\\swa.event_mask = ExposureMask | PointerMotionMask;Code:
while (!quit) {note: you may need to add Code:
#include <X11/Xutil.h>It seems you need to setup this ButtonPressMask and manualy call XSetInputFocus to get keyboard running in X app... I will post in near future very simple code with implemented handling of keyboard, mouse (touchscreen), accelerometer and opengles 2.0, as I'm still working on it :) it's also very modular, splitted into files like "accelerometer.h", "glinit.h", "glrender.h", etc. ; ) Hope this helps many developers to start developing :D ( because this whole setup is the hardest part I think... ) |
Re: Xlib+OpenGLES performace
Quote:
I edited the example already. I tested this on my phone and it works as desired. |
Re: Xlib+OpenGLES performace
Quote:
Argh, you don't need the above. Please set the proper WM_HINTS (the input hint at least), read http://tronche.com/gui/x/xlib/ICC/cl.../wm-hints.html |
Re: Xlib+OpenGLES performace
I've rewritten Exoticorn's sample to make it use my "new" library (which I call SDL_gles) that allows you to easily use OpenGL|ES (either 1.1 or 2.0) within your SDL applications.
Check it out here: http://git.maemo.org/git/sdlhildon/?...egl.cc;hb=HEAD . The entire initialization code gets reduced to Code:
SDL_Init(SDL_INIT_VIDEO);As you can guess, the event handling code is also very much simplified (getting keyboard input, mouse events, is as easy as with any SDL app). The library is already available on extras-devel (package name is "libsdl-gles1.2-dev", garage project is "sdlhildon"). For now, best documentation is the header itself on SDL_gles.h, but I plan to put some simpler examples later (or see the tests directory in git) |
Re: Xlib+OpenGLES performace
Quote:
Code:
Unpacking libsdl-gles1.2-1 (from .../libsdl-gles1.2-1_1.0.0_armel.deb) ... |
Re: Xlib+OpenGLES performace
Quote:
Code:
Nokia-N900-02-8:~# dpkg -l espeak-data libsdl-gles1.2-1If this is scratchbox you're talking about, I think there was a FAQ item about something like that but iirc was fixed in recent PR1.1 onwards rootstraps. |
Re: Xlib+OpenGLES performace
small remark regarding that example as shown on http://wiki.maemo.org/SimpleGL_example:
It uses GL_TRIANGLE_STRIP to draw a quad, but since 5 vertices are given, it actually draws 3 triangles. For triangle srtip, only 4 are needed, but you need to reorder the vertices. Or you just remove the last vertices and draw a GL_TRIANGLE_FAN Stumbled across this while porting the example to Python using ctypes, http://orgetik.de/wp/wordpress/?p=131 if anyone is interested. |
| All times are GMT. The time now is 21:35. |
vBulletin® Version 3.8.8