[Mesa-dev] [PATCH] st/mesa: find proper mipmap level in st_ClearTexSubImage()
Brian Paul
brianp at vmware.com
Wed Jul 5 16:41:07 UTC 2017
Please ignore for now. I need to take a closer look at interaction with
GL_ARB_texture_view...
-Brian
On 07/05/2017 10:31 AM, Brian Paul wrote:
> The Piglit arb_clear_texture-error test creates a texture with only
> a 1x1 image at level=1, then tries to clear level 0 (non-existant)
> and level 1 (exists). The test only checks that the former generates
> an error but the later doesn't. The test passes, but when we try
> to clear the level=1 image we're passing an invalid level to
> pipe_context::clear_texture(). level=1, but since there's only one
> mipmap level in the texture, it should be zero.
>
> This fixes the code to search the gallium texture resource for the
> correct mipmap level. Also, add an assertion to make sure we're not
> passing an invalid level to pipe_context::clear_texture().
>
> Fixes device errors with VMware driver. No Piglit regressions.
> ---
> src/mesa/state_tracker/st_cb_texture.c | 40 ++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
> index 1847cc3..6f05b01 100644
> --- a/src/mesa/state_tracker/st_cb_texture.c
> +++ b/src/mesa/state_tracker/st_cb_texture.c
> @@ -2836,6 +2836,42 @@ st_TextureView(struct gl_context *ctx,
> return GL_TRUE;
> }
>
> +
> +/**
> + * Find the mipmap level in 'pt' which matches the level described by
> + * 'texImage'.
> + */
> +static unsigned
> +find_mipmap_level(const struct gl_texture_image *texImage,
> + const struct pipe_resource *pt)
> +{
> + const GLenum target = texImage->TexObject->Target;
> + GLint texWidth = texImage->Width;
> + GLint texHeight = texImage->Height;
> + GLint texDepth = texImage->Depth;
> + unsigned level, w;
> + uint16_t h, d, layers;
> +
> + st_gl_texture_dims_to_pipe_dims(target, texWidth, texHeight, texDepth,
> + &w, &h, &d, &layers);
> +
> + for (level = 0; level <= pt->last_level; level++) {
> + if (u_minify(pt->width0, level) == w &&
> + u_minify(pt->height0, level) == h &&
> + u_minify(pt->depth0, level) == d) {
> + return level;
> + }
> + }
> +
> + /* If we get here, there must be some sort of inconsistency between
> + * the Mesa texture object/images and the gallium resource.
> + */
> + debug_printf("Inconsistent textures in find_mipmap_level()\n");
> +
> + return texImage->Level;
> +}
> +
> +
> static void
> st_ClearTexSubImage(struct gl_context *ctx,
> struct gl_texture_image *texImage,
> @@ -2864,6 +2900,10 @@ st_ClearTexSubImage(struct gl_context *ctx,
> box.z += texImage->TexObject->MinLayer;
> }
>
> + level = find_mipmap_level(texImage, pt);
> +
> + assert(level <= pt->last_level);
> +
> pipe->clear_texture(pipe, pt, level, &box, clearValue ? clearValue : zeros);
> }
>
>
More information about the mesa-dev
mailing list