mesa: add texobj support for ARB_texture_multisample

V2: - Allow multisample texture targets in glInvalidateTexSubImage too.
      This was already partly there, but I missed it the first time around
      since the interaction is defined in a newer extension. Fixed weird
      indentation.
    - Allow multisample array textures in glFramebufferTextureLayer.
      This was overlooked as the tests originally only used 2d
      multisample textures.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
tests: add ARB_texture_multisample enums to table

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: add new texture state for ARB_texture_multisample

V2: NumSamples and FixedSampleLocations are per-image state, not texture
object state.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: support getting current binding for multisample textures

V2: Use existing code for getting bound texobj names, for the new
targets

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
glsl: add support for ARB_texture_multisample

V2: emit `sample` parameter properly for multisample texelFetch()
V3: fix spurious whitespace change

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
wire up GL_TEXTURE_SAMPLES and GL_TEXTURE_FIXED_SAMPLE_LOCATIONS

V2: fixed for state being moved from texobj to image

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: add new max sample count state

- GL_MAX_COLOR_TEXTURE_SAMPLES
- GL_MAX_DEPTH_TEXTURE_SAMPLES
- GL_MAX_INTEGER_SAMPLES

V2: initialize limits to 1 in _mesa_init_constants as suggested by Brian
and Paul

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: expose new max sample counts

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: implement GetMultisamplefv

Actual sample locations deferred to a driverfunc since only the driver
really knows where they will be.

V2: pass the draw buffer to the driverfunc; don't fallback to pixel
center if driverfunc is missing.

V3: - rename GetSampleLocation to GetSamplePosition
    - invert y sample position for winsys FBOs, at Paul's suggestion

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: implement sample mask

V2: fix multiline comment style

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: add support for sample mask on Gen6+

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: expose sample positions

Moves the definition of the sample positions out of
gen6_emit_3dstate_multisample, and unpacks them in
gen6_get_sample_position.

V2: Be consistent about `sample position` rather than `location`.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: support multisample textures in framebuffer completeness check

- sample count must be the same on all attachments
- fixedsamplepositions must be the same on all attachments
(renderbuffers have fixedsamplepositions=true implicitly; only
multisample textures can choose to have it false)

V2: fix wrapping to 80 columns, debug message, fix for state moving from
texobj to image.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: adjust texture completeness for multisample

GL_TEXTURE_2D_MULTISAMPLE and GL_TEXTURE_2D_MULTISAMPLE_ARRAY targets
don't allow filtering state to be set, but the default state fails the
completeness check for integer formats.

We still care about other reasons the texture might be considered
incomplete though, so can't skip this entirely like GL_TEXTURE_BUFFER.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: allow stencil textures

ARB_texture_multisample allows STENCIL_INDEX and sized variants with the
multisample texture targets; similar to renderbuffers.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
mesa: implement TexImage*Multisample

V2: - fix formatting issues
    - generate GL_OUT_OF_MEMORY if teximage cannot be allocated
    - fix for state moving from texobj to image

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: add support for multisample textures

This is a bit nasty -- I've just (ab)used the existing multisample
renderbuffer path.

Also put the actual sample count from the mt back into the
renderbuffer so core mesa can see what the driver actually gave it.

V2: - fix for state moving from texobj to image
    - rebased onto Paul's logical/physical cleanup
    - fixed missing quantization of sample count

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: gen6: set multisample mode in surface_state

When setting up surface_state for texturing, set the multisample mode.
Surface_state used for render targets was already correct.

V2: Clarify commit message; rebased onto Paul's physical/logical dims
cleanup.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965: fix renderbuffer wrapper setup for multisample textures

Previously we were putting the 2x2 (or 4x2) fake dimensions of the
surface into the renderbuffer wrapper. This is different from how
other parts of the driver expect multisample renderbuffers to be set up,
and produced stalls and memory stomps.

Pulls multisample textures into line with classic multisample
renderbuffers, fixing the arb_texture_multisample-sample-mask-execution
-tex piglit.

V2: Rebased onto Paul's physical/logical dims cleanup

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
i965/vs: emit sample index for txf

When fetching texels from a multisample surface, the sample index is
provided as an extra argument after the lod, and the actual lod needs
to be hardwired to 0.

The frontend gives us the sample index in the lod parameter, so fix this
up.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>