TextureCache: Ensure that all render target textures have as many layers as the frame buffer.

Also fixes a case where the D3D code path did not initialize num_layers leading to undefined behaviour.