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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - AndiNo

Pages: [1]
1
Sorry for the late reply. I've been very busy during the last few days.

ProcessExplorer was a good idea. I've attached an image of the CPU usage while the program runs. I did not include the GPU graph, as it looked nearly identical to the CPU graph. At 60 fps the gaps are all 30 seconds long while the actual working time is about 20 seconds. Again I noticed that the gaps are a lot shorter if I use setFrameLimit instead of VSync.
However I could not obtain any new information about the topic. I guess it might have to do with my graphics card driver which I can not easily update because I'm using a laptop graphics card.
I will probably just ignore this behaviour and hope that it only appears on my computer. Maybe I'll test this again if a newer version of SFML becomes available.
Thanks for your effort :)

[attachment deleted by admin]

2
Thanks for your answer.
You're right, I do not measure FPS in any way other than looking at the screen and seeing that the counter should go up about 60 times per second, but doesn't do it when reaching the given amount of draw calls.

I tried your code but the "freezes" are still there. At about 988 draw calls the screen doesn't get updated anymore for about 10-20 seconds, then drawing goes on as usual. Sometimes during these freezes I can see that the FPS are below 1.

In the future I will probably use a different approach for drawing many objects, but it would be nice if anyone could figure out whether this is a bug in the code or if it's some unfortunate combination of software/hardware.

3
General / Severe unregular "lagging" when drawing a given number of shapes
« on: September 16, 2012, 11:50:27 pm »
Hi! I'm using the current precompiled SFML 2 RC (SJLJ) from the SFML website. I'm on a Win7 notebook with a AMD Radeon HD 6970M graphics card. Compiler is TDM-GCC 4.6.1.

In the following code I have a shape that gets drawn 'numDrawTiles' times per frame. I have VSync turned on.
The number of times the shape is drawn per frame increases every frame by one.
When the counter reaches about 987 draws per frame the framerate drops to 1FPS or lower instantly. When the counter reaches 1020 suddenly the program runs at 60FPS again. The next drop appears at about 2200 draws, this time however the "recovery time" is longer. After that it's back to normal ~60FPS again.

If I use setFramerateLimit(60) or disable VSync and do not limit the framerate the FPS drop is much less noticeable but still there.

My first assumption was that it might have to do with VSync, however this is not the case as stated above. For the record: I was able to draw about 8000 shapes per frame with approximately 30FPS so this is no usual FPS drop due to too many draw calls. I do also know that this is not the optimal way to draw many similar objects.

Code is below. Any ideas where this is coming from?


#include <SFML/Graphics.hpp>

// main rendering window
sf::RenderWindow mainWindow;

int main() {
        mainWindow.create(sf::VideoMode(640, 480), "Test");
//      mainWindow.setFramerateLimit(60);
        mainWindow.setVerticalSyncEnabled(true);

        sf::RectangleShape shape( sf::Vector2f(40, 40) );
        shape.setFillColor(sf::Color::Green);

        sf::Text counter;
        counter.setColor(sf::Color::Red);
        counter.setScale(3,3);

        unsigned long int tileCounter = 0;
        unsigned long int numDrawTiles = 1;

        while ( mainWindow.isOpen() == true )
        {
                sf::Event event;
                while (mainWindow.pollEvent(event))
                {
                        switch (event.type)
                        {
                                // window closed
                                case sf::Event::Closed:
                                        mainWindow.close();
                                        break;

                                // we don't process other types of events
                                default:
                                        break;
                        }
                }

                mainWindow.clear();

                tileCounter = 0;
                for(unsigned int i=0; i<numDrawTiles; ++i) {
                        shape.setPosition( 320, 240 );
                        mainWindow.draw(shape);
                        ++tileCounter;
                }
                ++numDrawTiles;

                char buffer[12];
                itoa(tileCounter, buffer, 10);
                counter.setString(buffer);
                mainWindow.draw(counter);

                mainWindow.display();
        }

        return 0;
}
 

Pages: [1]