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

Author Topic: sf::Texture initial slowdown  (Read 1676 times)

0 Members and 1 Guest are viewing this topic.

CDoughty08

  • Guest
sf::Texture initial slowdown
« on: March 30, 2015, 05:15:36 am »
First off thank you for your time.

I am noticing a seemingly odd slowdown with sf::Texture I can't seem to track down.
I built SFML from sources as a dynamic library ( possibly delayed DLL loading? )

Running in Debug build/Release build has absolutely no effect as well.
Relevant Snippets:
Test case
int main(int argc, char* argv[])
{
    size_t start = GetTickCount();
        size_t end = 0;
        sf::Texture tex;
        end = GetTickCount();

        printf("\nRuntime: %dms\n", (end - start));
        return 0;
}
 
Output average over 20 tries:
Runtime: 157ms

Any ideas on what causes this?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10991
    • View Profile
    • development blog
    • Email
AW: sf::Texture initial slowdown
« Reply #1 on: March 30, 2015, 07:15:20 am »
So what's the issue? Creating a texture will setup all kinds of OpenGL stuff (context etc). Are you really worried about 157ms at startup?

If it is bothering you, use the proper tool, i.e. a profiler, and find out what happens.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Dejan Geci

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: sf::Texture initial slowdown
« Reply #2 on: March 30, 2015, 08:17:43 am »
How about this?

int main(int argc, char* argv[])
{
    sf::Texture texInit;

    size_t start = GetTickCount();
    size_t end = 0;
    sf::Texture tex;
    end = GetTickCount();

    printf("\nRuntime: %dms\n", (end - start));
        return 0;
}

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: sf::Texture initial slowdown
« Reply #3 on: March 30, 2015, 09:00:29 pm »
As eXploit3r already said, is this really a problem?
Yes, creating a new texture takes some time, but you usually do that rarely. So it's usually no big deal.
But yes, ~150ms is quite a long time, is this an optimized build?

CDoughty08

  • Guest
Re: sf::Texture initial slowdown
« Reply #4 on: March 30, 2015, 10:26:25 pm »
It is not an "issue" per se. More curiosity than anything.
What does OpenGL have to do with it at that point though? The constructor for sf::Texture is empty and nothing in the initializer list seems to ask for a gl context?

Release -O2 is 140-150ms

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: sf::Texture initial slowdown
« Reply #5 on: March 30, 2015, 10:45:00 pm »
...... you really can't find it yourself??  Just because a ctor is empty doesn't mean there isn't a parent class ctor to execute.

https://github.com/SFML/SFML/blob/master/include/SFML/Graphics/Texture.hpp#L47

https://github.com/SFML/SFML/blob/master/src/SFML/Window/GlResource.cpp#L53
« Last Edit: March 30, 2015, 10:46:31 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10991
    • View Profile
    • development blog
    • Email
AW: sf::Texture initial slowdown
« Reply #6 on: March 30, 2015, 11:28:40 pm »
As I said, if you're curious run a profiler. It most likely will spend some time in the graphics driver.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything