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

Author Topic: SFML has HUGE GPU usage  (Read 4253 times)

0 Members and 1 Guest are viewing this topic.

blacksages

  • Newbie
  • *
  • Posts: 15
    • View Profile
SFML has HUGE GPU usage
« 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
« Last Edit: March 11, 2018, 02:36:56 pm by blacksages »

Chaia*

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: SFML has HUGE GPU usage
« Reply #1 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.

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML has HUGE GPU usage
« Reply #2 on: March 11, 2018, 06:50:44 pm »
You're probably running at thousands of FPS, you should use setFramerateLimit or setVerticalSyncEnabled.
Back to C++ gamedev with SFML in May 2023

 

anything