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

Author Topic: FPS  (Read 3385 times)

0 Members and 2 Guests are viewing this topic.

Garwin

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
FPS
« on: April 10, 2023, 09:05:58 am »
In my previous test (see https://en.sfml-dev.org/forums/index.php?topic=28998.0 I add simple fps counter:

        stepTime = std::chrono::steady_clock::now();
        duration = stepTime - startTime;
        startTime = stepTime;
        durationSec = duration.count();
        ++frames;
        fpsDuration += duration;
        if (fpsDuration > fpsUpdate)
        {
            fpsText.setString(std::to_string(static_cast<int>(frames/fpsDuration.count())));
            fpsDuration = std::chrono::duration<long double>::zero();
            frames = 0;
        }
 

And this is setting of window:
sf::ContextSettings settings;
settings.antialiasingLevel = 2;
sf::RenderWindow window{{static_cast<int>(width),static_cast<int>(height)}, "SFLM app", sf::Style::Fullscreen, settings };
 

I get following FPS for these setting using release version with gcc
1. 1400-1500 fps/s
800x600 - antialiasing 2
sf::Style::Default
2. 260-280 fps/s
1920x1080 - antialiasing 2
sf::Style::Default
3. 400-420 fps/s
1920x1080 - antialiasing 0
sf::Style::Default
4. 190-200 fps/s
1920x1080 - antialiasing 8
sf::Style::Default

Is it normal to have such drop of FPS between these resolutions? I am little worried that 200 FPS means 5 ms per frame, with 60 FPS has max 16 ms per second, just this simple rendering is taking 1/3 of max. time available.
As right now application does almost nothing (see link), what would be FPS with scalling resolution up in larger monitors switching antialiasing on?

note: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz   1.80 GHz, Intel(R) UHD Graphics 620
« Last Edit: April 10, 2023, 09:11:35 am by Garwin »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: FPS
« Reply #1 on: April 10, 2023, 03:59:30 pm »
Don't forget that FPS doesn't scale linearly. Thus a faster drop is expected, but then it won't continue to drop at the same pace.

When you draw more pixels and run AA filters, you need to expect to lose some frame time.
Measuring an empty scene however isn't representing anything, as it doesn't simulate a real scenario, so drawing conclusion from that can be misleading.

An Intel UHD Graphics 620 isn't exactly the best graphics chip, yielding terrible FPS counts for lots of games, it however should be fine for some limited 2D graphics. For more complex stuff, consider a dedicated GPU.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Garwin

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
Re: FPS
« Reply #2 on: April 10, 2023, 08:32:23 pm »
Don't forget that FPS doesn't scale linearly. Thus a faster drop is expected, but then it won't continue to drop at the same pace.

When you draw more pixels and run AA filters, you need to expect to lose some frame time.
Measuring an empty scene however isn't representing anything, as it doesn't simulate a real scenario, so drawing conclusion from that can be misleading.

An Intel UHD Graphics 620 isn't exactly the best graphics chip, yielding terrible FPS counts for lots of games, it however should be fine for some limited 2D graphics. For more complex stuff, consider a dedicated GPU.

Thanks for the answer. Intel UHD Graphics is not the best but still should be far enough as still capable of 3D graphics not most modern games.

I run a test to add sf::CircleShape entities to std::vector and see how many can be rendered with at least 60 FPS. With that resolution and antialiasing 8, I can get 500 entities. A rendering loop on top of the previous test was added changing the position of these 500 entities by random numbers (this addition is about 4 microseconds per loop, so really no effect). If I zoomed view out, FPS increased about twice. In case zoom was moved out of visible entities FPS increased to almost 200.

So it seems that I will need to go through sf::VertexArray directly.

What is the bottleneck of SFML drawing so I can focus on optimizing this part? I suspect draw call, so putting trying to put everything on sf::VertexArray can help and let just GUI be separated.

What about text? I expect to have sheets where there will be hundred or even slightly more texts (a lot of rows and columns).
Would be helpful to have a new class that will merge texts to a single one before the draw call?