SFML community forums

Help => Graphics => Topic started by: cu29p on March 09, 2019, 07:12:10 pm

Title: Alternative to texture.update(pixelBuffer)? (too slow)
Post by: cu29p 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
Title: Re: Alternative to texture.update(pixelBuffer)? (too slow)
Post by: Laurent 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.
Title: Re: Alternative to texture.update(pixelBuffer)? (too slow)
Post by: cu29p 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.
Title: Re: Alternative to texture.update(pixelBuffer)? (too slow)
Post by: FRex 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.