mesa: Pass number of samples as a program state variable

Number of samples will be required in fragment shader program by new
GLSL builtin uniform "gl_NumSamples".

V2: Use "state.numsamples" in place of "state.num.samples"
    Use _NEW_BUFFERS flag in place of _NEW_MULTISAMPLE

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ian Romanick <idr@freedesktop.org>
Reviewed-by: Ken Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
mesa: Add a helper function _mesa_is_sample_shading_enabled()
glsl: Add new builtins required by GL_ARB_sample_shading

New builtins added by GL_ARB_sample_shading:
in vec2 gl_SamplePosition
in int gl_SampleID
in int gl_NumSamples
out int gl_SampleMask[]

V2: - Use SWIZZLE_XXXX for STATE_NUM_SAMPLES.
    - Use "fragment.sampleid" and "fragment.samplepos"
      in arb_input_attrib_string.
    - Use "result.samplemask" in arb_output_attrib_string.
    - Add comment to explain the size of gl_SampleMask[] array.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
i965: Implement FS backend for ARB_sample_shading

Implement the FS backend for new builtins added by the extension:
in vec2 gl_SamplePosition
in int gl_SampleID
in int gl_NumSamples
out int gl_SampleMask[]

V2: Add more comments.
    Use fs_reg(0xffff) in AND instruction to get the 16 bit sample_mask.
    Handle num-samples = 1 as non-MSAA case in gl_SamplePosition.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
i965/gen6: Enable the features required for GL_ARB_sample_shading

- Enable GEN6_WM_MSDISPMODE_PERSAMPLE, GEN6_WM_POSOFFSET_SAMPLE,
  GEN6_WM_OMASK_TO_RENDER_TARGET as per extension's specification.
- Only enable one of GEN6_WM_8_DISPATCH_ENABLE or GEN6_WM_16_DISPATCH_ENABLE
  when GEN6_WM_MSDISPMODE_PERSAMPLE is enabled.
  Refer SNB PRM Vol. 2, Part 1, Page 279 for details.

V2: - Add a comment explaining why only SIMD8 mode is enabled with
      MSDISPMODE_PERSAMPLE.
    - Use shared function _mesa_is_sample_shading_enabled() to avoid
      code duplication.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
i965/gen7: Enable the features required for GL_ARB_sample_shading

- Enable GEN7_WM_MSDISPMODE_PERSAMPLE, GEN7_WM_POSOFFSET_SAMPLE,
  GEN7_WM_OMASK_TO_RENDER_TARGET as per extension's specification.
- Only enable one of GEN7_WM_8_DISPATCH_ENABLE or GEN7_WM_16_DISPATCH_ENABLE
  when GEN7_WM_MSDISPMODE_PERSAMPLE is enabled. Refer IVB PRM Vol. 2, Part 1,
  Page 288 for details.

V2: - Add a comment explaining why only SIMD8 mode is enabled with
      MSDISPMODE_PERSAMPLE.
    - Use shared function _mesa_is_sample_shading_enabled() to avoid
      code duplication.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
i965: Enable ARB_sample_shading on intel hardware >= gen6

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>