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

Author Topic: Best method for using a texture pool?  (Read 2544 times)

0 Members and 1 Guest are viewing this topic.

OddlyOrdinary

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Best method for using a texture pool?
« on: January 30, 2014, 07:28:18 pm »
Hi, I'm attempting to use a texture pool to display a 60fps video. I have a background thread that queues decoded frames that are 1080p, and is able to do so much faster than 60fps. I then seem to hit a bottleneck at the update texture operation. I'm using something like

VideoFrame frontFrame= vQueue->GetFrame();
if(frontFrame.frame)
{
      m_tex.update((sf::Uint8*)frontFrame.frame->data[0]);
}

If I have SFML running with setFrameLimit(0), and no vertical sync, I'm able to run really close to 60fps with some frames taking longer up to two frames. Just for info there is nothing else in this program besides the decode and the ten lines of SFML to update the texture and display it.

I'm currently trying to build a texture pool seperate from the main thread that rotates through 60 textures and calls the update on them. I'm using a single sprite to display them, and updating the texture the sprite points to each main loop.

sf::Texture* frameTexture = texturePool->GetFrameTexture();
if(frameTexture)
{
      renderHolder.setTexture(*frameTexture);   //renderHolder is a sf::sprite         
}      
window.draw(renderHolder);
 

This appears to be about the same performance as calling update directly. From the documentation I thought sf::Texture's update moved the pixel data to the gpu. So I was expecting the sprite updating to be much faster.

Any suggestions to increase performance?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Best method for using a texture pool?
« Reply #1 on: January 30, 2014, 08:18:13 pm »
I assume this is with an optimized release build and not an unoptimized debug build? If not, then building with optimization enabled is the obvious step one.

Step two (for me at least) would be to run the programme through a profiler and take a look at what it pinpoints as the top 5 resource eaters.

You should also check that your video card drivers are up to date since sometimes there are big leaps in performance between driver versions.

Just a few places to start  :)

krzat

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: Best method for using a texture pool?
« Reply #2 on: January 30, 2014, 08:32:58 pm »
OpenGL is basically single threaded so updating texture and drawing at the same time will not work.

60 fps seems kinda slow, check that your vsync is really disabled.
SFML.Utils - useful extensions for SFML.Net

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Best method for using a texture pool?
« Reply #3 on: January 31, 2014, 01:31:27 pm »
Why dont you try alternating between 2 textures and uploading it 1 frame earlier?

 

anything