Ideally we wouldn't SDL_RenderCopy the entire image buffers for every frame, but instead update only the currently active tile rectangles.
Profiling reveals that a good portion of CPU time is indeed spent on the main thread where it copies the image buffers 60 times a second.
Another option would of course be to just reduce the update loop timing to 20 or 30fps, but I really prefer the smooth 60fps updating, and I think it can be manageable if we just implement this correctly.
Another thing is, we're not using SDL_LockTexture at all yet.
I've been prototyping it like this recently, but it's still not working quite right:
Here it gathers all the actively rendered tiles, generates an SDL_Rect based on them and then tries to update only those regions, but I keep getting the offset wrong for some reason.
Ideally we wouldn't
SDL_RenderCopy
the entire image buffers for every frame, but instead update only the currently active tile rectangles. Profiling reveals that a good portion of CPU time is indeed spent on the main thread where it copies the image buffers 60 times a second.Another option would of course be to just reduce the update loop timing to 20 or 30fps, but I really prefer the smooth 60fps updating, and I think it can be manageable if we just implement this correctly. Another thing is, we're not using
SDL_LockTexture
at all yet.I've been prototyping it like this recently, but it's still not working quite right:
Here it gathers all the actively rendered tiles, generates an
SDL_Rect
based on them and then tries to update only those regions, but I keep getting the offset wrong for some reason.