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

Author Topic: efficient method for manipulating pixel data of surfaces/images  (Read 1752 times)

0 Members and 1 Guest are viewing this topic.

comme

  • Newbie
  • *
  • Posts: 2
    • View Profile
efficient method for manipulating pixel data of surfaces/images
« on: September 30, 2014, 10:28:24 pm »
Hi,
I want to draw directly to the renderwindow, and I see I can use sprites, images, textures, that sfml displays on the screen.
I am trying to avoid the overhead of copying megabytes of screen arrays around, my application is performance critical.
Is there any particular method/trick to manipulate the pixels or do I have to use update() (I remember the developer of this library saying years ago that it does a full copy)

Thanks for any input

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: efficient method for manipulating pixel data of surfaces/images
« Reply #1 on: September 30, 2014, 10:34:31 pm »
Oo, sounds really important!

I'd like to help but I can't do so for two reasons:
1) other people will be able to help a lot better than I,
2) I have no idea what you're trying to achieve.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: efficient method for manipulating pixel data of surfaces/images
« Reply #2 on: September 30, 2014, 10:55:46 pm »
If your application is performance critical use shaders, really!
If you don't use shaders, your application can't be performance critical, or you've left out the important information. You're then left with keeping a copy of sf::Image or better yet a std::vector<sf::Unit8> on the RAM, doing your pixel manipulation and then calling update() on the sf::Texture.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

comme

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: efficient method for manipulating pixel data of surfaces/images
« Reply #3 on: September 30, 2014, 11:31:40 pm »
If your application is performance critical use shaders, really!
If you don't use shaders, your application can't be performance critical, or you've left out the important information. You're then left with keeping a copy of sf::Image or better yet a std::vector<sf::Unit8> on the RAM, doing your pixel manipulation and then calling update() on the sf::Texture.
ah well. Thanks.

I need the best possible framerate I can get for my software rendering project.
I remember using sdl years ago and getting around 8000fps writing (almost) directly to vram, same with directdraw, but with update() I count very few fps....

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: efficient method for manipulating pixel data of surfaces/images
« Reply #4 on: September 30, 2014, 11:34:29 pm »
I don't know what you want to do or why, but I fail to see how triple digit (or more) FPS can be relevant. The human eye is not even close to being able to perceive that...

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: efficient method for manipulating pixel data of surfaces/images
« Reply #5 on: September 30, 2014, 11:59:35 pm »
Hmm... let's do some maths here...

Assume each pixel in the VRAM framebuffer is composed of a 24-bit RGB value.
At 8000 FPS, that would be...

8000 x 24 = 192000 bits per pixel per second

Say you had a more or less simple platformer with a scrolling background. Because you cannot assume that pixels stay the same from frame to frame, exploiting the temporal coherence of each frame (as with MPEG) isn't an option and you would have to end up transferring the whole screen's worth of data every frame.

Assume that the application was run in a 800x600 window. That is 480000 pixels to be updated every frame. This means that 92160000000 bits or 11.52 GB would have to be transferred every second from host to VRAM.

I'm interested, were you part of a special research group that had early access to 16-lane PCIe 3.0 GPUs back then? Because I don't see any other way a commercially produced GPU would be able to handle such high data transfer rates...

This was all of course based on a conservative estimate. The true values could be much larger ::).

Or... one of the assumptions is simply not true... I wonder which one it could be...
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

 

anything