I explicitly specify the OpenGL backend using SDL_HINT_RENDER_DRIVER, so I’m not getting batching by default in SDL 2.0.10. Can it be enabled at any time using SDL_HINT_RENDER_BATCHING, or is this (undocumented) hint only recognised if it is issued before the renderer is created?
The hint is checked during SDL_CreateRenderer(), and can not be changed for a renderer once created (but this means you can have two separate renderers exist at the same time that have this hint set differently).
If you’re explicitly setting the RENDER_DRIVER hint, you should set the RENDER_BATCHING hint too (if you don’t, it should still perform about at least as well as SDL 2.0.0 through 2.0.9 did!).
Will that work on all platforms, including Android and iOS, or only on desktop platforms?
I may try that but it will impact my code elsewhere because I call
glLogicOp() to set ‘logical’ plotting modes (AND, OR, XOR) - that’s the very reason that I force the OpenGL backend - so I will at least have to call
SDL_RenderFlush() before doing so.
It will work if you can have two renderers at the same time on Android, as batching isn’t a platform-specific thing, but I don’t know if that is possible or not.
Yep, that’s exactly what RenderFlush is used for!
What is the recommended cross-platform approach for calling
SDL_RenderFlush() when you can’t be sure it’s available (in my Linux releases I rely on the pre-built SDL2 binary from the relevant repository, so I don’t know what version it will be)? I can try to find its address at run time using
GetProcAddress() depending on the platform, but that’s really quite messy.
Could I cheat by calling another SDL2 function (one that exists in all versions) that has the side-effect of flushing the batching queue? I’m thinking of perhaps a dummy call like:
but I’d only want to do that if the overhead is low.