[Mesa-dev] [PATCH] i915: Initialize swrast_texture_image structure fields.

Ian Romanick idr at freedesktop.org
Thu Feb 16 23:39:28 PST 2012


On 02/16/2012 10:57 PM, Paul Berry wrote:
> Commit 980f6f1 (mesa: move gl_texture_image::Width/Height/DepthScale
> fields to swrast) moved the initialization of the Width, Height, and
> DepthScale fields to _swrast_alloc_texture_image_buffer().  However,
> i915 doesn't call this function because it performs its own buffer
> allocation.  As a result, the Width, Height, and DepthScale fields
> weren't getting initialized properly, and some operations requiring
> swrast would fail.
>
> This patch ensures that Width, Height, and DepthScale are properly
> initialized by separating the code that sets them into a new function,
> _swrast_init_texture_image(), which is called by
> intel_alloc_texture_image_buffer() as well as
> _swrast_alloc_texture_image_buffer().  It also moves the
> initialization of _IsPowerOfTwo into this function.
>
> Fixes piglit test fbo/fbo-cubemap on i915.

Reviewed-and-tested-by: Ian Romanick <ian.d.romanick at intel.com>

This should also be marked as a candidate for the 8.0 branch.

> Partially fixes https://bugs.freedesktop.org/show_bug.cgi?id=41216
> ---
>   src/mesa/drivers/dri/intel/intel_tex.c |    2 ++
>   src/mesa/swrast/s_texture.c            |   21 +++++++++++++++++++--
>   src/mesa/swrast/swrast.h               |    4 ++++
>   3 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c
> index 2ebd654..b3ac226 100644
> --- a/src/mesa/drivers/dri/intel/intel_tex.c
> +++ b/src/mesa/drivers/dri/intel/intel_tex.c
> @@ -84,6 +84,8 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
>      assert(!intel_image->base.ImageOffsets);
>      intel_image->base.ImageOffsets = malloc(slices * sizeof(GLuint));
>
> +   _swrast_init_texture_image(image, width, height, depth);
> +
>      if (intel_texobj->mt&&
>          intel_miptree_match_image(intel_texobj->mt, image)) {
>         intel_miptree_reference(&intel_image->mt, intel_texobj->mt);
> diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
> index 72d3093..9718367 100644
> --- a/src/mesa/swrast/s_texture.c
> +++ b/src/mesa/swrast/s_texture.c
> @@ -96,6 +96,25 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
>         swImg->ImageOffsets[i] = i * width * height;
>      }
>
> +   _swrast_init_texture_image(texImage, width, height, depth);
> +
> +   return GL_TRUE;
> +}
> +
> +
> +/**
> + * Code that overrides ctx->Driver.AllocTextureImageBuffer may use this to
> + * initialize the fields of swrast_texture_image without allocating the image
> + * buffer or initializing ImageOffsets or RowStride.
> + *
> + * Returns GL_TRUE on success, GL_FALSE on memory allocation failure.
> + */
> +void
> +_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width,
> +                           GLsizei height, GLsizei depth)
> +{
> +   struct swrast_texture_image *swImg = swrast_texture_image(texImage);
> +
>      if ((width == 1 || _mesa_is_pow_two(texImage->Width2))&&
>          (height == 1 || _mesa_is_pow_two(texImage->Height2))&&
>          (depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
> @@ -115,8 +134,6 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
>         swImg->HeightScale = (GLfloat) texImage->Height;
>         swImg->DepthScale = (GLfloat) texImage->Depth;
>      }
> -
> -   return GL_TRUE;
>   }
>
>
> diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
> index 468d22f..ad19eee 100644
> --- a/src/mesa/swrast/swrast.h
> +++ b/src/mesa/swrast/swrast.h
> @@ -192,6 +192,10 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
>                                      GLsizei height, GLsizei depth);
>
>   extern void
> +_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width,
> +                           GLsizei height, GLsizei depth);
> +
> +extern void
>   _swrast_free_texture_image_buffer(struct gl_context *ctx,
>                                     struct gl_texture_image *texImage);
>



More information about the mesa-dev mailing list