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

Author Topic: Extreme frame drop loading textures 256x256+  (Read 1970 times)

0 Members and 1 Guest are viewing this topic.

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Extreme frame drop loading textures 256x256+
« on: June 03, 2012, 12:42:36 am »
Hey guys!

Been working on my small game recently and have hit a wierd issue.. When I load a texture over a certain size (256x256) the game drops to about 3 frames per second.. if I don't load it, the frames go back to 60..

I am using a Graphics singleton that has a function that loads my textures, and stores them in a vector list which can be called from anywhere to access the textures to set them in sprites

std::vector <sf::Texture*> mTextureList;
 

void GraphicsManager::CreateTexture(const char* filename)
{
        sf::Texture* mTexture = new sf::Texture();

        if(!mTexture->loadFromFile(filename))
                std::cout << "Error loading texture: " + (char)filename << std::endl;
       
        this->GetTextureList().push_back(mTexture);
}

std::vector<sf::Texture*>& GraphicsManager::GetTextureList()
{
        return mTextureList;
}

 

I load all the textures in my GameEngine Init function as seen below
The texture causing the slow down is background1

void GameEngine::Init(const char* iTitle, int iWidth, int iHeight, bool iFullscreen)
{
        Graphics->InitWindow(iTitle, iWidth, iHeight, iFullscreen);

        m_running = true;
       
        Graphics->CreateTexture("survivor1.png");
        Graphics->CreateTexture("zombienormal.png");
        Graphics->CreateTexture("bullet.png");
        Graphics->CreateTexture("background1.png"); // < LARGE TEXTURE

        printf("GameEngine Init\n");
}
 

and I set textures to sprites like this (I know its not the perfect way but I want to work out why this is happening first)

this->GetSprite().setTexture( *Graphics->GetTextureList()[1] );
 

Anyone know why this massive slowdown is happening?

I have tried changing the texture etc, but any texture > then around 256x256 smashes performance.

WIERD THING.. I tried using the CPU Performance tester under Analyze > Launch Performance Wizard and this fixes everthing.. it stops the slowdown completely.. but if I run it without this.. the slowdown occurs..

Also - I am not even using the background texture, I am just loading it and it is causing the problem.. I am passing my stuff as reference.. so I am sure I am not making a copy of the texture when I get the texture list, so I don't know why this massive frame drops happening.

what the hell is going on?

Please help guys!

Thanks :)




« Last Edit: June 03, 2012, 12:53:05 am by 1337matty »
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Re: Extreme frame drop loading textures 256x256+
« Reply #1 on: June 03, 2012, 06:03:17 am »
Just re-did my entire image management with one on the wiki and the problem still happens! When loading a texture that's bigger then around 256/256 the entire game crashes down from 60 fps steady to about 2 fps...
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Extreme frame drop loading textures 256x256+
« Reply #2 on: June 03, 2012, 08:53:56 am »
What's your graphics card? Are your drivers up to date? Have you tried on someone else's PC?
Laurent Gomila - SFML developer

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Re: Extreme frame drop loading textures 256x256+
« Reply #3 on: June 03, 2012, 09:19:51 am »
2x ATI 6970's > updated to latest drivers too..

Dunno whats doing it :/

if i load 400 small sprites (64x64) no problem.. second I load ONE 256x256 + all messes up
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Re: Extreme frame drop loading textures 256x256+
« Reply #4 on: June 03, 2012, 02:03:36 pm »
argh.. 5 hours later no progress :( loading 100 256x256 textures - no problem! - load 1 256x256+ texture (eg 512x512) and 50% frame drop! ...

The wierdest part - when I run the CPU Sampler in VS2010.. it fixes the issue - second I stop running it - lag reappears...
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

atlasC1

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Extreme frame drop loading textures 256x256+
« Reply #5 on: June 05, 2012, 04:57:48 pm »
Are you running in debug or release mode? This can make a difference. Perhaps the profiler defaults to release mode or something (don't know, have never used it). Also, as far as I know, you generally want to avoid loading from disk when your frame rate is important. This is why games have loading screens; they load all of the large and important data into memory before the game starts, so you don't end up with slowdowns like the one you're experiencing.

Do you have another computer you could test it on?

-atlas

 

anything