mesa: Track number of layers in layered framebuffers.

In order to properly clear layered framebuffers, we need to know how
many layers they have.  The easiest way to do this is to record it in
the gl_framebuffer when we check framebuffer completeness, just like
we do for the Layered boolean.
!UPSTREAM: meta: fix meta clear of layered framebuffers

TODO:
- Improve commit message.
WIP: refactor blorp clearing code in preparation for adding layered clears
i965: Fix blorp clear of layered framebuffers.

Fixes piglit test "spec/!OpenGL 3.2/layered-rendering/clear-color".
i965: Fix fast clear of depth buffers.

Fixes piglit test "spec/!OpenGL 3.2/layered-rendering/clear-depth".
!UPSTREAM: main: check texture target when validating layered framebuffers.

From section 4.4.4 (Framebuffer Completeness) of the GL 3.2 spec:

    If any framebuffer attachment is layered, all populated
    attachments must be layered. Additionally, all populated color
    attachments must be from textures of the same target.

We weren't checking that the attachments were from textures of the
same target.

TODO:
- Make a piglit test for this, and validate it on Nvidia.