SFML community forums

Help => General => Topic started by: blacksages on March 11, 2018, 02:30:23 pm

Title: SFML has HUGE GPU usage
Post by: blacksages on March 11, 2018, 02:30:23 pm
Hi,
my task manager indicates my GPU usage jumps up to 90-98% when I launch my SFML application.
I used the code given in the tutorial:
Quote
int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

I'm on windows 10, i have a nvidia gtx 1050, i'm on laptop, I'm using codeblocks to compile.

I didn't pay attention to that until very soon, my much more complicated actual projet works fine, but the GPU usage jumps up to 95-97% :x

blacksages
Title: Re: SFML has HUGE GPU usage
Post by: Chaia* on March 11, 2018, 06:50:09 pm
I would not say this is a bad thing. You essentially do nothing but drawing a shape over an over again, so high GPU usage is in this case even the best case. Although, it is still interesting that you observe this. Usually I would expect that your CPU will bottleneck way earlier in this case, as you only draw very few triangles per draw call. Maybe your driver detects that you never change the shape and kind of caches the draw call but thats just a guess. How many FPS do you get? It could also be that your GPU stays in idle but I think thats unlikely.
Title: Re: SFML has HUGE GPU usage
Post by: FRex on March 11, 2018, 06:50:44 pm
You're probably running at thousands of FPS, you should use setFramerateLimit or setVerticalSyncEnabled.