[Mesa-stable] [Mesa-dev] [PATCH] st/mesa: use first image's dimensions when finalizing texture

Nicolai Hähnle nhaehnle at gmail.com
Mon Jun 6 21:37:58 UTC 2016


On 05.06.2016 08:24, Ilia Mirkin wrote:
> In the case where we can't guess the base level size, just use the first
> image's dims. The width0/height0/depth0 on stObj may not have been set
> at this point. Observed in a trace that set up levels 2..9 of a 2d texture,
> and set the base level to 2, with height 1. This made the guess logic
> always bail.

So by coincidence, I've been digging around this code today as well, 
though I think the issues we were looking at are unrelated.

I'm a bit confused. As far as I understand the code, the allocated pipe 
texture always has levels corresponding to the GL texture (ignoring 
texture views, at least...). So in the described situation, BaseLevel == 
2, stObj->lastLevel == 9, and we allocate a 10-level texture object.

The pipe texture dimensions should be the dimensions of a hypothetical 
level 0, but with your change they will end up being the dimension of 
the GL level 2, leading to a texture that is too small? How does this work?

I agree though that the current code can't be correct either...

Perhaps guess_base_level_size shouldn't bail on dim == 1 in the first place?

Cheers,
Nicolai

>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> Cc: "12.0" <mesa-stable at lists.freedesktop.org>
> ---
>   src/mesa/state_tracker/st_cb_texture.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
> index d38f24c..1dd1ef6 100644
> --- a/src/mesa/state_tracker/st_cb_texture.c
> +++ b/src/mesa/state_tracker/st_cb_texture.c
> @@ -2463,9 +2463,9 @@ st_finalize_texture(struct gl_context *ctx,
>                                    firstImage->base.Depth2,
>                                    firstImage->base.Level,
>                                    &width, &height, &depth)) {
> -         width = stObj->width0;
> -         height = stObj->height0;
> -         depth = stObj->depth0;
> +         width = stObj->width0 = firstImage->base.Width2;
> +         height = stObj->height0 = firstImage->base.Height2;
> +         depth = stObj->depth0 = firstImage->base.Depth2;
>         } else {
>            /* The width/height/depth may have been previously reset in
>             * guess_and_alloc_texture. */
>


More information about the mesa-stable mailing list