It only flushes when forced to. Specifically, in 2.0.10:
- When you call SDL_RenderPresent(), it flushes because it needs to get pixels to the screen.
- When you call SDL_SetRenderTarget(), if flushes because it needs to get pixels to the current render target before we start using a new one.
- When you call SDL_RenderReadPixels(), because we need it to have the right pixels rendered before we read them.
- When you Update/Lock/Bind/Unbind/Destroy a texture that’s been used by the renderer since the last flush, so we get the right texture data when drawing with stuff that’s been batched up.
- When you call SDL_RenderGetMetal*, so things are in sync.
- When you call SDL_RenderFlush(), because you’re telling it that you have to flush right now. Don’t call this unless you plan to use the underlying API directly and need things to be in sync (like if you plan to use the render API forced to OpenGL and also call OpenGL directly on that same rendering context).
The idea with batching, though, is that it should generally work like it always has, just faster. Specifically:
This will not flush at all in 2.0.10, assuming those SDL_Textures haven’t changed in some way between SDL render calls.
That being said, when flushing does happen, it benefits from using the same texture twice in a row, as SDL is now smart enough to only bind the texture once (in GL, Direct3D, etc) and draw from it multiple times, so you’ll see performance increases in this scenario beyond the higher-level “flushing” that SDL does.
The batching code started in 2.0.9, so you’d have to measure against 2.0.8 to see if there was a performance boost. There are a lot of factors that will dictate if this improves performance (not the least of which is: if you have vsync turned on and you were already rendering faster than 60fps, your framerate will never go above 60).
Also, if you’re forcing a renderer, either with the SDL_HINT_RENDER_DRIVER
hint or by giving a specific renderer’s index in SDL_CreateRenderer
, batching is disabled by default because we don’t know if you’re going to use a specific lower-level API directly and need the pre-batching behaviour from SDL. You can force batching on in this case with SDL_HINT_RENDER_BATCHING
.
–ryan.