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

Author Topic: Alternative to texture.update(pixelBuffer)? (too slow)  (Read 1687 times)

0 Members and 1 Guest are viewing this topic.

cu29p

  • Newbie
  • *
  • Posts: 2
    • View Profile
Alternative to texture.update(pixelBuffer)? (too slow)
« on: March 09, 2019, 07:12:10 pm »
Hi,
I'm editing pixels on my 1920x1080 buffer. To draw it I'm updating the texture with update(buffer) and then drawing it via its Sprite.

Checking my FPS while not drawing anything, but while using the update function I'm getting max 300 FPS.
Removing the update function I'm getting 4k FPS.

If there is no alternative, what is the exact problem for this function to be so slow?
Is the texture copying my buffer into another buffer of the RAM? Making it unnecessarily slow?
Where would that buffer be and how could I access it?

thanks

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Alternative to texture.update(pixelBuffer)? (too slow)
« Reply #1 on: March 10, 2019, 08:41:25 am »
Don't benchmark with FPS, it's a non-linear scale that don't mean much at high numbers.

Your full-screen pixel update takes less than 3 ms, so I wouldn't call that "slow". Finish your app/game and make tests in real situations, don't waste your time with a single function in an empty program.
Laurent Gomila - SFML developer

cu29p

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Alternative to texture.update(pixelBuffer)? (too slow)
« Reply #2 on: March 11, 2019, 02:51:02 am »
Thank you, and yea you are right. I just thought it's weird that updating the texture takes more time than actually editing my buffer, since I'm drawing 36k particles in a 3D software renderer. In the end FPS drop from 130 to 110 frames when using this function, so I guess that's normal. Though if there was a buffer of the texture that I can directly write into it would be even better.

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Alternative to texture.update(pixelBuffer)? (too slow)
« Reply #3 on: March 11, 2019, 03:39:33 am »
Maybe OpenGL pixel unpack buffer could help here? SFML doesn't provide that though so you'd have to write your own code for that.
Back to C++ gamedev with SFML in May 2023