[Mesa-dev] [PATCH 10/12] intel: Add support for LLC-cached reads of X-tiled miptrees using a blit.

Chad Versace chad.versace at linux.intel.com
Tue Dec 6 10:58:14 PST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/05/2011 11:42 AM, Eric Anholt wrote:
> This mimics the MapRenderbuffer code, and should improve the
> performance of glGetTexImage().
> ---
>  src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   83 ++++++++++++++++++++++++
>  src/mesa/drivers/dri/intel/intel_mipmap_tree.h |    2 +
>  2 files changed, 85 insertions(+), 0 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
> index c1805fc..126ae06 100644
> --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
> @@ -687,6 +687,82 @@ intel_miptree_unmap_gtt(struct intel_context *intel,
>  }
>  
>  static void
> +intel_miptree_map_blit(struct intel_context *intel,
> +		       struct intel_mipmap_tree *mt,
> +		       struct intel_miptree_map *map,
> +		       unsigned int level, unsigned int slice)
> +{
> +   unsigned int image_x, image_y;
> +   int x = map->x;
> +   int y = map->y;
> +   int ret;
> +
> +   /* The blitter requires the pitch to be aligned to 4. */
> +   map->stride = ALIGN(map->w * mt->region->cpp, 4);
> +
> +   map->bo = drm_intel_bo_alloc(intel->bufmgr, "intel_miptree_map_blit() temp",
> +				map->stride * map->h, 4096);
> +   if (!map->bo) {
> +      fprintf(stderr, "Failed to allocate blit temporary\n");
> +      goto fail;
> +   }
> +
> +   intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
> +   x += image_x;
> +   y += image_y;
> +
> +   if (!intelEmitCopyBlit(intel,
> +			  mt->region->cpp,
> +			  mt->region->pitch, mt->region->bo,
> +			  0, mt->region->tiling,
> +			  map->stride / mt->region->cpp, map->bo,
> +			  0, I915_TILING_NONE,
> +			  x, y,
> +			  0, 0,
> +			  map->w, map->h,
> +			  GL_COPY)) {
> +      fprintf(stderr, "Failed to blit\n");
> +      goto fail_unmap;
> +   }
> +
> +   intel_batchbuffer_flush(intel);
> +   ret = drm_intel_bo_map(map->bo, (map->mode & GL_MAP_WRITE_BIT) != 0);
> +   if (ret) {
> +      fprintf(stderr, "Failed to map blit temporary\n");
> +      goto fail;
> +   }
> +
> +   map->ptr = map->bo->virtual;
> +
> +   DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__,
> +       map->x, map->y, map->w, map->h,
> +       mt, _mesa_get_format_name(mt->format),
> +       x, y, map->ptr, map->stride);
> +
> +   return;
> +
> +fail_unmap:
> +   drm_intel_bo_unmap(map->bo);

This is an unbalanced unmap. When fail_unmap is jumped to, the bo has not been mapped yet.

I don't see any need at all for the fail_unmap label. If the blit fails, the code should
just jump to 'fail'.

> +fail:
> +   drm_intel_bo_unreference(map->bo);
> +   map->ptr = NULL;
> +   map->stride = 0;
> +}
> +

- ----
Chad Versace
chad.versace at linux.intel.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJO3mXFAAoJEAIvNt057x8ixDcQAKi6+9d/SUDPLvkN0+QPH7ye
BkRPko1dHlgKn+ovYmLngA85ndlZ7zlQRB8pA0LTEvbubE5yEQZYhs1/pltpuOV+
1SLDzdRxGVTXJLk07v9wlYf23/ihzolcqg0pqsE4GiFNcmG/qdpBN6M8czbnPja3
DxL+xPsHw9xI8AErO2hSFIA82AlDfq6OVY1jbgMs68TOCzQ5bUpMcd/XYlFGT7D4
rz8fXlZMJTuCrxLuyScs/PcLpE+vOU3jwleHWe6DH9jMBZP/CeNHwkv2+cnIh66F
YbbkVHIMpbrlPYNSVBXiPosEozE5UiRIu6yRstv5rvgdRWkhyZ10y87d97su7Xj4
A5XKic8CHpJp3hzG0L3IimIm8j+OBgL4R5tHNYBytNXDJTHWW5ZSXUbtQ7a9m998
+R/hkcsqGCJPO4K2GHHi9pdo8USpxO4vHbsYeCtS5Hst0g6KW4HLz6EXu1UG9Z4r
rar5m1wM6DVxRV+zON/BXxOKwtzMsx6C/j6XRGpMYXbxTTwjCDXzE8e5n+xE7X6C
xCkCe/CDbUJbmYTeY3W8jV1bKIXkbz+ibeBtjVtWbxFW4kM/CLuATY9bUZTfrSdw
fPrSOseZI0WeRsrmULIANEe4/jkdYc75H8SXSXDk/l7OKCZ/1aLHUN8AB0Itq4BX
lI/3sYD9CndA/jw/JArO
=s/us
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list