[Mesa-dev] [PATCH] i965: Use sample barycentric coordinates with per sample shading

Anuj Phogat anuj.phogat at gmail.com
Mon Jan 13 18:28:02 PST 2014


On Mon, Jan 13, 2014 at 1:06 PM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
>
> On Fri, Jan 10, 2014 at 5:25 PM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
> > On Thu, Jan 9, 2014 at 4:34 PM, Chris Forbes <chrisf at ijw.co.nz> wrote:
> >> Hi Anuj,
> >>
> >> There's one fiddly interaction that I don't think this handles quite
> >> right, although I think it does conform.
> >>
> >> Suppose we have this fragment shader:
> >>
> >>    #version 330
> >>    #extension ARB_gpu_shader5: require
> >>
> >>    sample in vec4 a;
> >>    in vec4 b;
> >>
> >>    ...
> >>
> >> Then `b` is being evaluated at the sample position as well. This is
> >> allowed by my reading of the spec, but probably not what the author
> >> expected.
> > Good catch.
> >>
> >> From the ARB_gpu_shader5 spec, emphasis mine:
> >>
> >>     (11) Should we support per-sample interpolation of attributes?  If so,
> >>          how?
> >>
> >>       RESOLVED.  Yes.  When multisample rasterization is enabled, qualifying
> >>       one or more fragment shader inputs with "sample" will force per-sample
> >>       interpolation of those attributes.  If the same shader includes other
> >>       fragment inputs not qualified with sample, those attributes _may_ be
> >>       interpolated per-pixel (i.e., all samples get the same values, likely
> >>       evaluated at the pixel center).
> >>
> >> What do you think?
> > I agree with your interpretation. Spec seems to be flexible about it. I'll check
> > what NVIDIA does in this case. This should be easy to fix if we need to.
> I verified that NVIDIA doesn't evaluate variable 'b' at sample position.
> I'll send out an updated patch to match this behavior.
>
Chris,
I identified another case not very well defined by OpenGL specs:
/* Enable sample shading using OpenGL API */
glEnable(GL_SAMPLE_SHADING);
glMinSampleShading(1.0);

fragment shader:
#version 130
in vec4 a;
centroid in vec4 b;
...
Variable 'a' will be interpolated at sample location. What
interpolation should we
use for variable 'b' ?

ARB_sample_shading says:
" Should there be an option to specify that all fragment shader inputs
   be interpolated at per-sample frequency?  If so, how?
   RESOLVED:  Yes. Via the enable"

" When the sample shading fraction is 1.0, a separate set of colors and
   other associated data are evaluated for each sample, each set of values
   are evaluated at the sample location."

If we follow ARB_sample_shading 'b' should be interpolated at sample position.

But GLSL 400 (and previous versions) spec says that:
"When an interpolation qualifier is used, it overrides settings established
  through the OpenGL API." This text got deleted in later versions of GLSL.

If we follow GLSL 400 (or earlier) 'b' should use centroid interpolation. For
later versions of GLSL 'b' should be interpolated at sample position.

NVIDIA's and AMD's proprietary linux drivers (at OpenGL 4.3) interpolates at
sample position. I think we should also stick to this behavior. Any views?

>
> >>
> >> -- Chris


More information about the mesa-dev mailing list