On 10/25/2013 04:45 PM, Anuj Phogat wrote: > Thsi function is used to test if we need to do per sample shading or > per fragment shading. > > Signed-off-by: Anuj Phogat <anuj.pho...@gmail.com>
With the one change mentioned below, this patch is Reviewed-by: Ian Romanick <ian.d.roman...@intel.com> > --- > src/mesa/program/program.c | 31 +++++++++++++++++++++++++++++++ > src/mesa/program/program.h | 3 +++ > 2 files changed, 34 insertions(+) > > diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c > index 093d372..e12e6ec 100644 > --- a/src/mesa/program/program.c > +++ b/src/mesa/program/program.c > @@ -1024,3 +1024,34 @@ _mesa_postprocess_program(struct gl_context *ctx, > struct gl_program *prog) > > } > } > + > +/* Gets the minimum number of shader invocations per fragment. > + * This function is useful to determine if we need to do per > + * sample shading or per fragment shading. > + */ > +GLint > +_mesa_get_min_invocations_per_fragment(struct gl_context *ctx, > + const struct gl_fragment_program > *prog) > +{ > + /* From ARB_sample_shading specification: > + * "Using gl_SampleID in a fragment shader causes the entire shader > + * to be evaluated per-sample." > + * > + * "Using gl_SamplePosition in a fragment shader causes the entire > + * shader to be evaluated per-sample." > + * > + * "If MULTISAMPLE or SAMPLE_SHADING_ARB is disabled, sample shading > + * has no effect." > + */ > + if (ctx->Multisample.Enabled) { > + if (prog->Base.SystemValuesRead & SYSTEM_BIT_SAMPLE_ID || > + prog->Base.SystemValuesRead & SYSTEM_BIT_SAMPLE_POS) if (prog->Base.SystemValuesRead & (SYSTEM_BIT_SAMPLE_ID | SYSTEM_BIT_SAMPLE_POS)) > + return ctx->DrawBuffer->Visual.samples; > + else if (ctx->Multisample.SampleShading) > + return ceil(ctx->Multisample.MinSampleShadingValue * > + ctx->DrawBuffer->Visual.samples); > + else > + return 1; > + } > + return 1; > +} > diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h > index 34965ab..353ccab 100644 > --- a/src/mesa/program/program.h > +++ b/src/mesa/program/program.h > @@ -187,6 +187,9 @@ _mesa_valid_register_index(const struct gl_context *ctx, > extern void > _mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog); > > +extern GLint > +_mesa_get_min_invocations_per_fragment(struct gl_context *ctx, > + const struct gl_fragment_program > *prog); > > static inline GLuint > _mesa_program_target_to_index(GLenum v) > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev