maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Xlib+OpenGLES performace (https://talk.maemo.org/showthread.php?t=37356)

exoticorn 2009-12-15 22:21

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

hhedberg 2009-12-16 10:46

Re: Xlib+OpenGLES performace
 
Quote:

Originally Posted by exoticorn (Post 429657)

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?

Most probably. See this post in Maemo Developers mailing list:

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.

kwotski 2009-12-16 11:07

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 ;) )

exoticorn 2009-12-16 11:32

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.

kwotski 2009-12-16 11:53

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;

if(!donesetup) {

        XGetWindowAttributes(dpy, win, &gwa);
        glViewport(0, 0, gwa.width, gwa.height);
        glClearColor(0, 1, 0, 1);
        glClear(GL_COLOR_BUFFER_BIT);
        donesetup = 1;
}


exoticorn 2009-12-16 12:21

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.

kwotski 2009-12-16 12:33

Re: Xlib+OpenGLES performace
 
See, I learned something ;)

javispedro 2009-12-16 12:51

Re: Xlib+OpenGLES performace
 
Quote:

Originally Posted by exoticorn (Post 429657)
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?

Either wait for next firmware release or see this post.

javispedro 2009-12-16 13:08

Re: Xlib+OpenGLES performace
 
Quote:

Originally Posted by exoticorn (Post 430317)
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.

The Xlib call, on the other side, is a roundtrip to the X server. Removing it (along with all the another unneeded "finish" calls) wins a few fps.

With that and the above I get around 43fps.

exoticorn 2009-12-16 13:45

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.


All times are GMT. The time now is 11:42.

vBulletin® Version 3.8.8