This is a very general question, and not aimed at any particular language or graphics API; I am more interested in the theories & algorithms behind the solutions.
I'm reasonably familiar with the basic idea behind shadow mapping:
Each spotlight and directional light requires a rendering pass to generate it's shadow map, and each point light requires 6 such passes, prior to any lighting calculations.
Such a potentially large number of rendering passes could quite easily have a substantial negative impact on performance and texture bandwidth, so how do modern game engines deal with this problem, especially in the case with deferred rendering systems, where many lights are involved?
Consider the following scenario:
A scene contains a reasonable amount of geometry, spread out over a "level". That level has a certain number (let's say 20, for brevity) stationary point lights dotted around the level. The player can place lights around the level too, and carries a torch (spotlight).
The rendering system uses the deferred shading model, given the potentially high number of lights in the scene.
How does the renderer decide which lights to render shadowmaps for? Of those lights, during the "light pass", how is that variable number of shadow maps handled dynamically, bearing in mind that they could be 2d textures (spots and directional), or cube maps (points)?
Do graphics API's have the capability to support shaders with arrays of maps/lights, or would the shadow maps require a single discrete lighting pass for each individual light?