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>
i965/fs: 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>
i965: enable ARB_texture_multisample on Gen6

There are a few things that need to be done to support Gen7+ as well,
but I don't have a machine available to test them.

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