[Mesa-dev] [PATCH 1/2] mesa: Implement ARB_texture_filter_minmax

Emil Velikov emil.l.velikov at gmail.com
Mon Nov 20 12:12:56 UTC 2017


Hi Scott,

I think there's a few missed checks if the extensions is enabled.

On 14 November 2017 at 22:54, Scott D Phillips
<scott.d.phillips at intel.com> wrote:

> @@ -218,6 +218,7 @@ _legal_parameters(struct gl_context *ctx, GLenum target, GLenum internalformat,
>     case GL_VIEW_COMPATIBILITY_CLASS:
>     case GL_NUM_TILING_TYPES_EXT:
>     case GL_TILING_TYPES_EXT:
> +   case GL_TEXTURE_REDUCTION_MODE_ARB:
Here.

> @@ -1464,6 +1489,9 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
> @@ -1536,6 +1564,9 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
> @@ -1608,6 +1639,9 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params)
> @@ -1680,6 +1714,9 @@ _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params)
>           goto invalid_pname;
>        *params = (GLenum) sampObj->sRGBDecode;
>        break;
> +   case GL_TEXTURE_REDUCTION_MODE_ARB:
And these four?

> --- a/src/mesa/main/texparam.c
> +++ b/src/mesa/main/texparam.c
> @@ -630,6 +630,25 @@ set_tex_parameteri(struct gl_context *ctx,
>        }
>        goto invalid_pname;
>
> +   case GL_TEXTURE_REDUCTION_MODE_ARB:
> +      if (ctx->Extensions.ARB_texture_filter_minmax) {
> +
> +         if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
> +            goto invalid_enum;
> +
> +         if (texObj->Sampler.ReductionMode == params[0])
> +            return GL_FALSE;
> +         if (params[0] == GL_MIN ||
> +             params[0] == GL_MAX ||
> +             params[0] == GL_WEIGHTED_AVERAGE_ARB) {
> +            flush(ctx);
> +            texObj->Sampler.ReductionMode = params[0];
> +            return GL_TRUE;
> +         }
> +         goto invalid_param;
> +      }
> +      goto invalid_pname;
> +
Using the 'return early' approach will make it easier to read ...
although the function is inconsistent so meh.
Just an example, I'm talking about:

   case GL_TEXTURE_REDUCTION_MODE_ARB:
      if (!ctx->Extensions.ARB_texture_filter_minmax)
         goto invalid_pname;

      if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
         goto invalid_enum;

      if (texObj->Sampler.ReductionMode == params[0])
         return GL_FALSE;

      if (params[0] != GL_MIN &&
          params[0] != GL_MAX &&
          params[0] != GL_WEIGHTED_AVERAGE_ARB)
         goto invalid_param;
      }

      flush(ctx);
      texObj->Sampler.ReductionMode = params[0];
      return GL_TRUE;


HTH
Emil


More information about the mesa-dev mailing list