[Mesa-dev] [PATCH 04/16] intel: Rely on Mesa core for glTexImage storage.

Brian Paul brianp at vmware.com
Thu Sep 29 16:02:28 PDT 2011


On 09/29/2011 04:39 PM, Eric Anholt wrote:
> ---
>   src/mesa/drivers/dri/intel/intel_tex_image.c |   59 ++++----------------------
>   1 files changed, 8 insertions(+), 51 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
> index c0f609f..8c87a25 100644
> --- a/src/mesa/drivers/dri/intel/intel_tex_image.c
> +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
> @@ -403,61 +403,18 @@ intelTexImage(struct gl_context * ctx,
>         return;
>      }
>
> -   pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
> -					format, type,
> -					pixels, unpack, "glTexImage");
> -
> -   if (intelImage->mt) {
> -      if (pixels != NULL) {
> -	 /* Flush any queued rendering with the texture before mapping. */
> -	 if (drm_intel_bo_references(intel->batch.bo,
> -				     intelImage->mt->region->bo)) {
> -	    intel_flush(ctx);
> -	 }
> -         texImage->Data = intel_miptree_image_map(intel,
> -                                                  intelImage->mt,
> -                                                  intelImage->base.Base.Face,
> -                                                  intelImage->base.Base.Level,
> -&dstRowStride,
> -                                                  intelImage->base.Base.ImageOffsets);
> -      }
> -
> -      texImage->RowStride = dstRowStride / intelImage->mt->cpp;
> -   }
> -
>      DBG("Upload image %dx%dx%d row_len %d pitch %d pixels %d\n",
>          width, height, depth, width * texelBytes, dstRowStride,
>          pixels ? 1 : 0);
>
> -   /* Copy data.  Would like to know when it's ok for us to eg. use
> -    * the blitter to copy.  Or, use the hardware to do the format
> -    * conversion and copy:
> -    */
> -   if (pixels) {
> -      if (!_mesa_texstore(ctx, dims,
> -			  texImage->_BaseFormat,
> -			  texImage->TexFormat,
> -			  texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
> -			  dstRowStride,
> -			  texImage->ImageOffsets,
> -			  width, height, depth,
> -			  format, type, pixels, unpack)) {
> -	 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
> -      }
> -   }
> -
> -   _mesa_unmap_teximage_pbo(ctx, unpack);
> -
> -   if (intel->must_use_separate_stencil
> -&&  texImage->TexFormat == MESA_FORMAT_S8_Z24) {
> -      intel_tex_image_s8z24_create_renderbuffers(intel, intelImage);
> -      intel_tex_image_s8z24_scatter(intel, intelImage);
> -   }
> -
> -   if (intelImage->mt) {
> -      if (pixels != NULL)
> -         intel_miptree_image_unmap(intel, intelImage->mt);
> -      texImage->Data = NULL;
> +   if (pixels || _mesa_is_bufferobj(unpack->BufferObj)) {
> +      _mesa_store_teximage3d(ctx, target, level, internalFormat,
> +                             width, height, depth, border,
> +                             format, type, pixels,
> +                             unpack, texObj, texImage);
> +   } else {
> +      ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
> +                                          width, height, depth);
>      }
>   }
>

I think you can simplify this even more.

I think you can omit the conditional and always call 
_mesa_store_teximage3d() because that function will call 
ctx->Driver.AllocTextureImageBuffer() and return early if there's no 
pixel data to put into the texture buffer.

-Brian


More information about the mesa-dev mailing list