Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: OpenGL performance issue  (Read 6108 times)

0 Members and 1 Guest are viewing this topic.

dreimalbla

  • Newbie
  • *
  • Posts: 6
    • View Profile
OpenGL performance issue
« on: July 26, 2008, 08:37:05 pm »
Hi,

we've got a big OpenGL performance problem here.

We are programming a space strategy game using SFML. The framework got bigger and bigger and we are dealing with huge performance problems right now.

Here are the main features which will give you a little review of our situation:

-There are about 9 planets which are drawn and rotating.
-We calculate Point on Map of the Mouse every Frame.
-1 Light Source
-Zoom, Move Map, Rotate around fixed point on Map is possible

At the moment we reach about 200 fps in window mode.
(Graphic Card: 9800 Pro ATI Radeon, CPU amd 2500+)

My friend with an ATI x800xt and amd 3500+ gets about 350 fps. We're both using the newest catalyst drivers (8.7).

To trace the bottleneck we stopped the time for some functions. This didn't really work out because there are two functions which take the most time, drawFunctions and
eventfunction(incl. Point on Map calculation).

Therefore we wrote 2 simple OpenGL testprograms. One in SDL and one in SFML.
There's only some drawing without much calculation at events and without texturing and lighting.

We are drawing 9 gluSpheres with 32 slices and 32 stacks which are rotating in front of a black background.

For testing we also included DisplayLists.

Here are my Results (the x800xt results):

SFML
draw: about 700fps (1000fps)
draw with DL(DisplayLists): about 1500 fps (2800fps)

SDL
draw: about 1000 fps (1800fps)
draw with DL: about 1700 fps (3000fps)

Now the real big difference can be seen in FULLSCREEN mode:

FULLSCREEN
SFML
draw: about 700fps (900fps)
draw with DL(DisplayLists): about 1600 fps (3100fps)

SDL
draw: about 1100 fps (1800fps)
draw with DL: about 3400 fps (6200fps)

Sure, we would like to stick with SFML, because we are big fans of this library and it is really good, but since
we got this performance problem we are wondering if we should switch to SDL.

Maybe someone here can tell us why there is such a big differnce in FULLSCREEN Mode to SDL?

We could post the source of the two testprograms if needed. We tried to have the same things activated at those programs on
each libaray. Is it possible that there are tweaks in SFML that we aren't aware of? If so please help us and tell us how we can improve our program using SFML. Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL performance issue
« Reply #1 on: July 27, 2008, 05:45:45 am »
If you're using SFML window package only (ie. to get a window and a working OpenGL context), you should have no performance penalty because it actually does nothing after initialization.

You should show us your code, at least the way you're initializing and using SFML.
Laurent Gomila - SFML developer

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
OpenGL performance issue
« Reply #2 on: July 27, 2008, 11:26:28 am »
You could use a profiler to find out what the bottleneck is.
A short question: Are you running Vista?
I get only about half of the performance I get on XP or Linux (on the same system). I always thought that it was a driver related problem, but maybe it is something different...

tno

  • Newbie
  • *
  • Posts: 9
    • View Profile
OpenGL performance issue
« Reply #3 on: July 27, 2008, 05:06:43 pm »
Hi,

so we changed it from RenderWindow to Window, but unfortunately without any improvment.

Maybe someone can name us here a good profiler, because we tried gDebugger but couldn't get really along with it.

We are both using XP because we knew there would be trouble with vista and OpenGL drivers, etc...

here is the init part:
Code: [Select]


sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Fullscreen);

 // Enable Z-buffer read and write
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    glClearDepth(1.f);
glClearColor(0.f, 0.f, 0.f, 0.f);

    // Setup a perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 500.f);

    glColor4f(1.f, 1.f, 1.f, 1.f);


and the while loop:
Code: [Select]

    while (App.IsOpened())
    {

if(cullFaceActive)
glEnable(GL_CULL_FACE);
else
glDisable(GL_CULL_FACE);

        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();


if ((Event.Type == sf::Event::KeyPressed) ) {

switch(Event.Key.Code){
case sf::Key::F2:
displayListActive = !displayListActive;
if(displayListActive)
printf("DRAW with DisplayList: TRUE \n");
else
printf("DRAW with DisplayList: FALSE \n");
break;
case sf::Key::Escape:
App.Close();
break;
default:
break;
}
}
        }



        // Clear depth buffer
        glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);

        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        if (drawActive) {
actualGameTime = (float)timeClass->getElapsedGameTime();
glTranslatef(0.f, 0.f, -200.f);

glRotatef(actualGameTime * 50, 1.f, 0.f, 0.f);
glRotatef(actualGameTime * 30, 0.f, 1.f, 0.f);
glRotatef(actualGameTime * 90, 0.f, 0.f, 1.f);

draw();
}


        // Finally, display the rendered frame on screen
App.Display();

fps = (float)timeClass->getFPS(&avgFPS, &avgCounter);
    }



-tno

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
OpenGL performance issue
« Reply #4 on: July 27, 2008, 05:07:29 pm »
Quote from: "Avency"
You could use a profiler to find out what the bottleneck is.
A short question: Are you running Vista?
I get only about half of the performance I get on XP or Linux (on the same system). I always thought that it was a driver related problem, but maybe it is something different...


Like: Vista is total crap?

Code: [Select]
glClearColor(0.f, 0.f, 0.f, 0.f);

Hum...

Code: [Select]
glClearColor(0.f, 0.f, 0.f, 1.f);

Maybe?
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL performance issue
« Reply #5 on: July 27, 2008, 05:20:14 pm »
Could you try to reduce the code to the minimal piece which still shows the difference ?
Laurent Gomila - SFML developer

tno

  • Newbie
  • *
  • Posts: 9
    • View Profile
OpenGL performance issue
« Reply #6 on: July 27, 2008, 11:16:27 pm »
I hope I understand you right, here is the reduced code:

initial part:
Code: [Select]
sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Fullscreen);


while loop:

I asume, the event part is almost the same but i will leave it here..
Code: [Select]

while (App.IsOpened())
    {
   
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();


         if ((Event.Type == sf::Event::KeyPressed) ) {

            switch(Event.Key.Code){
               case sf::Key::F2:
                  displayListActive = !displayListActive;
                  if(displayListActive)
                     printf("DRAW with DisplayList: TRUE \n");
                  else
                     printf("DRAW with DisplayList: FALSE \n");
                  break;
               case sf::Key::Escape:
                  App.Close();
                  break;
               default:
                  break;
            }
         }
        }

      //DRAW SPHERES...

        // Finally, display the rendered frame on screen
      App.Display();

    }


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
OpenGL performance issue
« Reply #7 on: July 28, 2008, 02:51:23 am »
Not exactly, I meant a complete piece of code which still shows the difference, but without your specific code (minimal event handling, a simple rendering function instead of draw(), etc.) ;)

Something that I can try at home, and doesn't require hours of testing to see where the "bottleneck" is.
Laurent Gomila - SFML developer

tno

  • Newbie
  • *
  • Posts: 9
    • View Profile
OpenGL performance issue
« Reply #8 on: July 28, 2008, 10:35:31 pm »
Hi again,

i have minimized the 2 testprograms.

They were both tested under VS 2008 WinXp and working, dll, lib files are included in the projects so it should work without any changes, just compile debug / release mode and run. At least i hope so :)

I think the two programs are only working under Windows correct, is this a problem for you Laurent?

Short Keyboard notice:

F1 - Draw de-/activate
F2 - Enable/Disable DisplayLists
F3 - Enable/Disable CullFace
Esc - End program

Both programs start in FullScreen.

For further help see readme.txt File in the zip File.

http://rapidshare.de/files/40105123/SFML_SDL_OpenGLTest.zip.html :D

elisee

  • Full Member
  • ***
  • Posts: 108
    • View Profile
OpenGL performance issue
« Reply #9 on: July 30, 2008, 10:14:22 pm »
I might be missing the point here, but did you make sure you enabled the "optimize for OpenGL calls" SFML option ?

Well actually it seems it's not relevant to your case but I think it's called
sf::RenderWindow::PreserveOpenGLStates    ()

 

anything