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

Author Topic: Is it normal GPU usage?  (Read 3422 times)

0 Members and 1 Guest are viewing this topic.

MrOnlineCoder

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Is it normal GPU usage?
« on: August 25, 2016, 07:40:46 pm »
Hello. I am drawing on game screen ~12 sprites each frame on 120 fps and it "eats" 20% of my GPU and CPU. My GPU is 775 MHz, so 20% is ~155 MHz. Is it normal?

JohnGreek

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Is it normal GPU usage?
« Reply #1 on: August 25, 2016, 09:59:29 pm »
Hi.
How did you find out the GPU usage %? Did you use a tool like CPU-Z?
In my i7 @2.2Gz laptop a main loop is about 5-13%(one core).
One suggestion is after loop processing to write:

sf::sleep(sf::milliseconds(1));

This enables the CPU "rest" a bit between the main loop cycles and return control to the OS.
In my past games/apps i was around 20-30% and after i used this it dropped to the aforementioned %.


Edit: One more thing i discovered some time ago is that i had downloaded "modded" GPU drivers(my gfx card was itegrated graphics) and although CPU was around 20% i was rendering like 2-3fps. When i removed the modded and installed the official ones it worked normal.
« Last Edit: August 25, 2016, 10:02:54 pm by JohnGreek »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10825
    • View Profile
    • development blog
    • Email
Re: Is it normal GPU usage?
« Reply #2 on: August 25, 2016, 10:26:38 pm »
There's no need to use a sleep call yourself. SFML provides setFramerateLimit or setVerticalSyncEnabled
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Is it normal GPU usage?
« Reply #3 on: August 26, 2016, 01:07:33 pm »
This sounds most likely like you're having no frame rate limit (neither a maxed frame rate nor vertical synchronization). As such the program simply runs as fast as possible, maxing out as much as it can.

Try enabling either and your usage should go down significantly.

MrOnlineCoder

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Re: Is it normal GPU usage?
« Reply #4 on: August 26, 2016, 09:50:44 pm »
Nope, I set framerate limit on start. I used Process Hacker to get GPU/CPU Usage

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Is it normal GPU usage?
« Reply #5 on: August 26, 2016, 10:56:59 pm »
Then you're doing something wrong or you're somehow running software rendering. Can you show us some code?

MrOnlineCoder

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Re: Is it normal GPU usage?
« Reply #6 on: August 26, 2016, 11:01:18 pm »
Ok. So framerate limit is 60 by default but user can change it by setting "--fps XX" launch option. Main.cpp parses all launch options and send them to engine.

Engine::Engine(LaunchOptions options)
{
    Uint32 style = Style::Close | Style::Titlebar;

    if (options.fullscreen) {
        style = Style::Fullscreen;
    } else {
        style = Style::Close | Style::Titlebar;
    }
    eLog("Constructor called!");
    app.create(VideoMode(1024, 768), "Game", style);
    app.setFramerateLimit(options.maxFPS);
}

 


I send reference of window to my game screens (state).

Honor

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Is it normal GPU usage?
« Reply #7 on: August 27, 2016, 01:44:18 pm »
Try forcing your framerate to something lower? Just to ensure there is absolutely no issues with your parser?

app.setFramerateLimit(options.maxFPS);
to
app.setFramerateLimit(30);

MrOnlineCoder

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Re: Is it normal GPU usage?
« Reply #8 on: August 27, 2016, 08:34:01 pm »
If "--fps" flag is not set, then options.maxFPS = 60, it has same GPU usage without flag.

 

anything