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

Author Topic: PBO Drawbacks and Implementation ?  (Read 3864 times)

0 Members and 1 Guest are viewing this topic.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
PBO Drawbacks and Implementation ?
« on: April 16, 2010, 02:27:46 am »
I was taking a look at PBO demos over at: http://www.songho.ca/opengl/gl_pbo.html

What are the drawbacks to using PBOs?

Using a double PBO I was able to go from 300 MB/s to 550+ and 70 fps to 140.

It seems like it would be good for sprite streaming, no?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
PBO Drawbacks and Implementation ?
« Reply #1 on: April 16, 2010, 08:36:40 am »
What do you call "sprite streaming"?
Laurent Gomila - SFML developer

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
PBO Drawbacks and Implementation ?
« Reply #2 on: April 16, 2010, 01:34:00 pm »
I think he means things like playing video onto a sprite

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
PBO Drawbacks and Implementation ?
« Reply #3 on: April 16, 2010, 01:40:55 pm »
So it's rather "image streaming" ;)

Anyway, did you make any benchmark before saying that I should implement something faster? Some users have implemented video playback and didn't report sf::Image being too slow, so far.
Laurent Gomila - SFML developer

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
PBO Drawbacks and Implementation ?
« Reply #4 on: April 16, 2010, 03:47:22 pm »
Hey guys.

Yes, I meant streaming images to sprites.


This wasn't a feature request right now so much as general discussion.


The main problem I see to PBOs for sprite images is that the GPU will be too busy for shaders, right?


I think the biggest bottleneck for me right now is LoadPixels and SubRect.

Maybe first I should try to write my own code to SubRect through direct byte manipulation.

I already need to replace GetPixel and SetPixel for speed.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
PBO Drawbacks and Implementation ?
« Reply #5 on: April 16, 2010, 04:04:57 pm »
Quote
The main problem I see to PBOs for sprite images is that the GPU will be too busy for shaders, right?

The GPU is usually idle, waiting for the CPU to complete all the driver calls made by SFML. Even if you use shaders.

Quote
I think the biggest bottleneck for me right now is LoadPixels and SubRect.

You should profile your code before optimizing anything. By the way, what are you doing? How do you use LoadFromPixels? Why do you think that SetSubRect is a bottleneck (internally it doesn't do anything except assigning the rect)?

Quote
I already need to replace GetPixel and SetPixel for speed.

For speed you should never use them, and rather work on your own array of pixels, then use LoadFromPixels (or UpdatePixels in SFML 2).
Laurent Gomila - SFML developer

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
PBO Drawbacks and Implementation ?
« Reply #6 on: April 16, 2010, 05:22:40 pm »
Quote from: "Laurent"

The GPU is usually idle, waiting for the CPU to complete all the driver calls made by SFML. Even if you use shaders.

You should profile your code before optimizing anything. By the way, what are you doing? How do you use LoadFromPixels? Why do you think that SetSubRect is a bottleneck (internally it doesn't do anything except assigning the rect)?

For speed you should never use them, and rather work on your own array of pixels, then use LoadFromPixels (or UpdatePixels in SFML 2).


I just meant for this to be a general discussion and theory for PBO in SFML. I'm going to make another thread on what I'm doing which is processing image(s) in my tool.

Spodi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://www.netgore.com/
PBO Drawbacks and Implementation ?
« Reply #7 on: April 16, 2010, 06:09:31 pm »
Quote from: "Ashenwraith"

The main problem I see to PBOs for sprite images is that the GPU will be too busy for shaders, right?


Look at what your game is doing. Then look at what modern games are doing. If you're using SFML, you probably just have a bunch of 2D shapes drawn on the screen. Modern games are drawing complex 3D models, smoothing them, applying lighting and shadows, creating reflective surfaces, and tons of other shader effects. To make the GPU "too busy", you have to give it more to do than just draw rectangles. The max amount you can draw in SFML is more likely going to be determined by maxing out the bus or too much overhead from OpenGL calls, not actually maxing out the GPU.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
PBO Drawbacks and Implementation ?
« Reply #8 on: April 16, 2010, 06:18:38 pm »
Quote from: "Spodi"
Quote from: "Ashenwraith"

The main problem I see to PBOs for sprite images is that the GPU will be too busy for shaders, right?


Look at what your game is doing. Then look at what modern games are doing. If you're using SFML, you probably just have a bunch of 2D shapes drawn on the screen. Modern games are drawing complex 3D models, smoothing them, applying lighting and shadows, creating reflective surfaces, and tons of other shader effects. To make the GPU "too busy", you have to give it more to do than just draw rectangles. The max amount you can draw in SFML is more likely going to be determined by maxing out the bus or too much overhead from OpenGL calls, not actually maxing out the GPU.


That really depends.

When you're dealing with 1000's and 1000's of HD (1920x1080 res) sprites you aren't using massive polygons, but you are eating up texture memory. Yes there is compression and optimization, but how you process and manage them in game is something you have to carefully approach.

 

anything