Is it possible to switch between multiple render targets without loosing data?

I was trying to switch from rendering directly to the window to more suitable, to more suitable technique - rendering the scene to the texture and then rendering the result onto the screen. But the problem is, that while rendering the scene, there is some caching going on, involving rendering some anims to the texture first, and in so doing avoiding the necessity to render the same animation multiple times. But it seems all the data rendered before switching between render targets is lost. Am I missing something, or doing something dumb, and is there an easy way to fix this?

Have you tried calling SDL_RenderFlush() before switching targets?

I did, however, I got very weird result - it seems it worked only on every n-th frame

Ok, that was my stupid fault - I was clearing the texture after every target switch