Is there a significant benefit (or any benefit at all), when I convert SDL surface and create a texture from optimized surface?

Here is example of what I mean:

loadedSurface = IMG_Load(path);
optimSurface = SDL_ConvertSurface(loadedSurface, SURFACE_FORMAT, 0);
loadedTexture = SDL_CreateTextureFromSurface(renderer, optimSurface);
//return loadedTexture and destroy the rest

/*  VS  */

loadedSurface = IMG_Load(path);
loadedTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
//return loadedTexture and destroy the rest

According to SDL2 documentation

This function is used to optimize images for faster repeat blitting. This is accomplished by converting the original and storing the result as a new surface. The new, optimized surface can then be used as the source for future blits, making them faster.

Its tied with surface blitting, but I can't say its effect "within" texture.

Thank you


Check the source for SDL_CreateTextureFromSurface. It calls SDL_ConvertSurface already. So using SDL_ConvertSurface is entirely redundant.

I took a quick peek at what SDL_ConvertSurface does in the SDL source code (GitHub mirror here), and it seems to just change surface internals, if even that.

The only way I could imagine that had an effect would be to save on the conversion/data transmit that is performed when the texture data is sent onto the GPU, but I highly doubt that actually makes a difference here. So I would not call SDL_ConvertSurface.

In general, with SDL2, you can discard most of the surface manipulation, since the focus is in the hardware accelerated renderer.

  • 1
    \$\begingroup\$ Yes, you are right! Thank you for pointing me to the sources. It's much easier to see than I thought. \$\endgroup\$ – Jakub Bures Nov 3 '18 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.