[Mesa-dev] [PATCH 2/2] i965: Respect driconf option clamp_max_samples

Paul Berry stereotype441 at gmail.com
Fri Nov 1 22:37:33 CET 2013


On 31 October 2013 18:36, Chad Versace <chad.versace at linux.intel.com> wrote:

> Clamp gen7 GL_MAX_SAMPLES to 0, 4, or 8.
> Clamp gen6 GL_MAX_SAMPLES to 0 or 4.
> Clamp other gens to 0.
>
> CC: Eric Anholt <eric at anholt.org>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
>  src/mesa/drivers/dri/i965/brw_context.c  | 35
> +++++++++++++++++++++++---------
>  src/mesa/drivers/dri/i965/intel_screen.c |  1 +
>  2 files changed, 26 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 38147e9..60a201f 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -273,6 +273,10 @@ brw_initialize_context_constants(struct brw_context
> *brw)
>  {
>     struct gl_context *ctx = &brw->ctx;
>
> +   uint32_t max_samples;
> +   const uint32_t *legal_max_samples;
> +   uint32_t clamp_max_samples;
> +
>     ctx->Const.QueryCounterBits.Timestamp = 36;
>
>     ctx->Const.StripTextureBorder = true;
> @@ -333,19 +337,30 @@ brw_initialize_context_constants(struct brw_context
> *brw)
>
>     ctx->Const.AlwaysUseGetTransformFeedbackVertexCount = true;
>
> -   if (brw->gen == 6) {
> -      ctx->Const.MaxSamples = 4;
> -      ctx->Const.MaxColorTextureSamples = 4;
> -      ctx->Const.MaxDepthTextureSamples = 4;
> -      ctx->Const.MaxIntegerSamples = 4;
> -   } else if (brw->gen >= 7) {
> -      ctx->Const.MaxSamples = 8;
> -      ctx->Const.MaxColorTextureSamples = 8;
> -      ctx->Const.MaxDepthTextureSamples = 8;
> -      ctx->Const.MaxIntegerSamples = 8;
> +   if (brw->gen >= 7) {
> +      legal_max_samples = (uint32_t[]){8, 4, 0};
>        ctx->Const.MaxProgramTextureGatherComponents = 4;
> +   } else if (brw->gen == 6) {
> +      legal_max_samples = (uint32_t[]){4, 0};
> +   } else {
> +      legal_max_samples = (uint32_t[]){0};
> +   }
> +
> +   /* Set max_samples = min(max(legal_max_samples), clamp_max_samples). */
>

I don't think the comment matches your intention.  How about this instead?

   /* Set max_samples to the first (and hence largest) element of
    * legal_max_samples that is <= clamp_max_samples.  Or, if
    * clamp_max_samples < 0, simply the first element of legal_max_samples.
    */



> +   max_samples = 0;
> +   clamp_max_samples = driQueryOptioni(&brw->optionCache,
> "clamp_max_samples");
> +   for (uint32_t i = 0; legal_max_samples[i] != 0; ++i) {
> +      if (legal_max_samples[i] <= clamp_max_samples) {
> +         max_samples = legal_max_samples[i];
> +         break;
> +      }
>

If clamp_max_samples < 0, this code sets max_samples to 0.  That's not what
you want; you want it to be set to legal_max_samples[0] in this case.


>     }
>
> +   ctx->Const.MaxSamples = max_samples;
> +   ctx->Const.MaxColorTextureSamples = max_samples;
> +   ctx->Const.MaxDepthTextureSamples = max_samples;
> +   ctx->Const.MaxIntegerSamples = max_samples;
> +
>     ctx->Const.MinLineWidth = 1.0;
>     ctx->Const.MinLineWidthAA = 1.0;
>     ctx->Const.MaxLineWidth = 5.0;
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c
> b/src/mesa/drivers/dri/i965/intel_screen.c
> index eafafa2..0e991ec 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -67,6 +67,7 @@ DRI_CONF_BEGIN
>     DRI_CONF_SECTION_END
>     DRI_CONF_SECTION_QUALITY
>        DRI_CONF_FORCE_S3TC_ENABLE("false")
> +      DRI_CONF_CLAMP_MAX_SAMPLES()
>     DRI_CONF_SECTION_END
>     DRI_CONF_SECTION_DEBUG
>        DRI_CONF_NO_RAST("false")
> --
> 1.8.3.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131101/7d964292/attachment.html>


More information about the mesa-dev mailing list