Context switches

I wanted to render some robots with a shadow map applied for self shadowing. I thought I’d create a nice big texture and reuse it to create a shadow for each character.

This kills the frame rate. Even if I don’t actually render anything to the texture, the cost of switching contexts in killer (on a GF4Ti anyway).

Is switching contexts just a really expensive thing and if I want it to work I can really only draw one shadow map for the entire scene instead of one per character?

Why are you switching contexts?
Are you using render-to-texture?

Originally posted by knackered:
Why are you switching contexts?
Are you using render-to-texture?

Yeah, I’ve got a bunch of textures (mostly shadow maps) I use each frame which are different than the previous frame.

As they needed to be regenerated I thought it would be smart to simply reuse the texture and save the memory for the static textures.

Context switches shouldn’t be overly expensive. Switch times should be insignificant compared to time it takes to render to the texture. If not, then you’ll have to push nVidia to speed things up I suppose.

You’re using ARB_Render_texture, yes (along with the other assiciated extensions)? It is known that nVidia’s implementation of this extension isn’t terribly well optimized. Some have speculated that an internal texture copy operation is involved.