# Should I call SDL_ConvertSurface right before SDL_CreateTextureFromSurface?

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);
//return loadedTexture and destroy the rest

/*  VS  */

//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.

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