[Mesa-dev] [PATCH 5/5] i965/tex: Unify the TexImage and TexSubImage code

Iago Toral itoral at igalia.com
Fri Sep 15 08:25:20 UTC 2017


On Thu, 2017-09-14 at 20:10 -0700, Kenneth Graunke wrote:
> From: Jason Ekstrand <jason.ekstrand at intel.com>
> 
> It's nearly the same so there's no good reason why it can't be in a
> common function.  The one difference is that _mesa_store_teximage
> calls AllocTextureImageBuffer for us, while _mesa_store_texsubimage
> doesn't, but we don't need that anyway - intelTexImage already does
> it.

Right, we were allocating memory twice for that code path...

For the series:
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/intel_tex_image.c | 103 ++++++++++++----
> ------------
>  1 file changed, 45 insertions(+), 58 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c
> b/src/mesa/drivers/dri/i965/intel_tex_image.c
> index 29a49840d81..ceb0b3f9810 100644
> --- a/src/mesa/drivers/dri/i965/intel_tex_image.c
> +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
> @@ -283,6 +283,45 @@ intel_texsubimage_tiled_memcpy(struct gl_context
> * ctx,
>  }
>  
>  
> +static void
> +intel_upload_tex(struct gl_context * ctx,
> +                 GLuint dims,
> +                 struct gl_texture_image *texImage,
> +                 GLint xoffset, GLint yoffset, GLint zoffset,
> +                 GLsizei width, GLsizei height, GLsizei depth,
> +                 GLenum format, GLenum type,
> +                 const GLvoid * pixels,
> +                 const struct gl_pixelstore_attrib *packing)
> +{
> +   struct intel_mipmap_tree *mt = intel_texture_image(texImage)->mt;
> +   bool ok;
> +
> +   bool tex_busy = mt && brw_bo_busy(mt->bo);
> +
> +   if (mt && mt->format == MESA_FORMAT_S_UINT8)
> +      mt->r8stencil_needs_update = true;
> +
> +   ok = _mesa_meta_pbo_TexSubImage(ctx, dims, texImage,
> +                                   xoffset, yoffset, zoffset,
> +                                   width, height, depth, format,
> type,
> +                                   pixels, tex_busy, packing);
> +   if (ok)
> +      return;
> +
> +   ok = intel_texsubimage_tiled_memcpy(ctx, dims, texImage,
> +                                       xoffset, yoffset, zoffset,
> +                                       width, height, depth,
> +                                       format, type, pixels,
> packing);
> +   if (ok)
> +     return;
> +
> +   _mesa_store_texsubimage(ctx, dims, texImage,
> +                           xoffset, yoffset, zoffset,
> +                           width, height, depth,
> +                           format, type, pixels, packing);
> +}
> +
> +
>  static void
>  intelTexImage(struct gl_context * ctx,
>                GLuint dims,
> @@ -290,11 +329,6 @@ intelTexImage(struct gl_context * ctx,
>                GLenum format, GLenum type, const void *pixels,
>                const struct gl_pixelstore_attrib *unpack)
>  {
> -   struct intel_texture_image *intelImage =
> intel_texture_image(texImage);
> -   bool ok;
> -
> -   bool tex_busy = intelImage->mt && brw_bo_busy(intelImage->mt-
> >bo);
> -
>     DBG("%s mesa_format %s target %s format %s type %s level %d
> %dx%dx%d\n",
>         __func__, _mesa_get_format_name(texImage->TexFormat),
>         _mesa_enum_to_string(texImage->TexObject->Target),
> @@ -307,34 +341,11 @@ intelTexImage(struct gl_context * ctx,
>        return;
>     }
>  
> -   assert(intelImage->mt);
> -
> -   if (intelImage->mt->format == MESA_FORMAT_S_UINT8)
> -      intelImage->mt->r8stencil_needs_update = true;
> -
> -   ok = _mesa_meta_pbo_TexSubImage(ctx, dims, texImage, 0, 0, 0,
> -                                   texImage->Width, texImage-
> >Height,
> -                                   texImage->Depth,
> -                                   format, type, pixels,
> -                                   tex_busy, unpack);
> -   if (ok)
> -      return;
> +   assert(intel_texture_image(texImage)->mt);
>  
> -   ok = intel_texsubimage_tiled_memcpy(ctx, dims, texImage,
> -                                       0, 0, 0, /*x,y,z offsets*/
> -                                       texImage->Width,
> -                                       texImage->Height,
> -                                       texImage->Depth,
> -                                       format, type, pixels,
> unpack);
> -   if (ok)
> -      return;
> -
> -   DBG("%s: upload image %dx%dx%d pixels %p\n",
> -       __func__, texImage->Width, texImage->Height, texImage->Depth,
> -       pixels);
> -
> -   _mesa_store_teximage(ctx, dims, texImage,
> -                        format, type, pixels, unpack);
> +   intel_upload_tex(ctx, dims, texImage, 0, 0, 0,
> +                    texImage->Width, texImage->Height, texImage-
> >Depth,
> +                    format, type, pixels, unpack);
>  }
>  
>  
> @@ -348,38 +359,14 @@ intelTexSubImage(struct gl_context * ctx,
>                   const GLvoid * pixels,
>                   const struct gl_pixelstore_attrib *packing)
>  {
> -   struct intel_mipmap_tree *mt = intel_texture_image(texImage)->mt;
> -   bool ok;
> -
> -   bool tex_busy = mt && brw_bo_busy(mt->bo);
> -
> -   if (mt && mt->format == MESA_FORMAT_S_UINT8)
> -      mt->r8stencil_needs_update = true;
> -
>     DBG("%s mesa_format %s target %s format %s type %s level %d
> %dx%dx%d\n",
>         __func__, _mesa_get_format_name(texImage->TexFormat),
>         _mesa_enum_to_string(texImage->TexObject->Target),
>         _mesa_enum_to_string(format), _mesa_enum_to_string(type),
>         texImage->Level, texImage->Width, texImage->Height, texImage-
> >Depth);
>  
> -   ok = _mesa_meta_pbo_TexSubImage(ctx, dims, texImage,
> -                                   xoffset, yoffset, zoffset,
> -                                   width, height, depth, format,
> type,
> -                                   pixels, tex_busy, packing);
> -   if (ok)
> -      return;
> -
> -   ok = intel_texsubimage_tiled_memcpy(ctx, dims, texImage,
> -                                       xoffset, yoffset, zoffset,
> -                                       width, height, depth,
> -                                       format, type, pixels,
> packing);
> -   if (ok)
> -     return;
> -
> -   _mesa_store_texsubimage(ctx, dims, texImage,
> -                           xoffset, yoffset, zoffset,
> -                           width, height, depth,
> -                           format, type, pixels, packing);
> +   intel_upload_tex(ctx, dims, texImage, xoffset, yoffset, zoffset,
> +                    width, height, depth, format, type, pixels,
> packing);
>  }
>  
>  


More information about the mesa-dev mailing list