[Mesa-dev] [PATCH] st/mesa: simplify lastLevel determination in st_finalize_texture

Nicolai Hähnle nhaehnle at gmail.com
Thu May 24 08:18:29 UTC 2018


Seems plausible, although that code tends to be tricky as hell. Assuming 
no piglit / CTS regressions:

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>


On 23.05.2018 22:43, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> This fixes shader images where we always bind stObj->pt and not individual
> gl_texture_images.
> 
> Roughly based on i965 commit 845ad2667ab2466752f06ea30bdb9c837116c308
> which does a similar thing but for a different reason.
> 
> This fixes GL CTS assertion failures introduced by Ilia.
> 
> Cc: 18.0 18.1 <mesa-stable at lists.freedesktop.org>
> ---
>   src/mesa/state_tracker/st_cb_texture.c | 17 ++++-------------
>   1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
> index 8cc8e08a623..40a1ce11087 100644
> --- a/src/mesa/state_tracker/st_cb_texture.c
> +++ b/src/mesa/state_tracker/st_cb_texture.c
> @@ -2484,33 +2484,24 @@ st_finalize_texture(struct gl_context *ctx,
>      const GLuint nr_faces = _mesa_num_tex_faces(stObj->base.Target);
>      GLuint face;
>      const struct st_texture_image *firstImage;
>      enum pipe_format firstImageFormat;
>      unsigned ptWidth;
>      uint16_t ptHeight, ptDepth, ptLayers, ptNumSamples;
>   
>      if (tObj->Immutable)
>         return GL_TRUE;
>   
> -   if (_mesa_is_texture_complete(tObj, &tObj->Sampler)) {
> -      /* The texture is complete and we know exactly how many mipmap levels
> -       * are present/needed.  This is conditional because we may be called
> -       * from the st_generate_mipmap() function when the texture object is
> -       * incomplete.  In that case, we'll have set stObj->lastLevel before
> -       * we get here.
> -       */
> -      if (stObj->base.Sampler.MinFilter == GL_LINEAR ||
> -          stObj->base.Sampler.MinFilter == GL_NEAREST)
> -         stObj->lastLevel = stObj->base.BaseLevel;
> -      else
> -         stObj->lastLevel = stObj->base._MaxLevel;
> -   }
> +   if (tObj->_MipmapComplete)
> +      stObj->lastLevel = stObj->base._MaxLevel;
> +   else if (tObj->_BaseComplete)
> +      stObj->lastLevel = stObj->base.BaseLevel;
>   
>      /* Skip the loop over images in the common case of no images having
>       * changed.  But if the GL_BASE_LEVEL or GL_MAX_LEVEL change to something we
>       * haven't looked at, then we do need to look at those new images.
>       */
>      if (!stObj->needs_validation &&
>          stObj->base.BaseLevel >= stObj->validated_first_level &&
>          stObj->lastLevel <= stObj->validated_last_level) {
>         return GL_TRUE;
>      }
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list