<br><br><div class="gmail_quote">On Wed, Mar 7, 2012 at 4:28 PM, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Mon 27 Feb 2012 11:45:46 AM PST, Anuj Phogat wrote:<br>
> This patch handles a case when mapping a large texture fails<br>
> in drm_intel_gem_bo_map_gtt(). These changes avoid assertion<br>
> failure later in the driver as reported in following bugs:<br>
><br>
> <a href="https://bugs.freedesktop.org/show_bug.cgi?id=44970" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=44970</a><br>
> <a href="https://bugs.freedesktop.org/show_bug.cgi?id=46303" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=46303</a><br>
><br>
> Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>><br>
> ---<br>
> src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 26 ++++++++++++++++-------<br>
> src/mesa/drivers/dri/intel/intel_regions.c | 7 ++++-<br>
> 2 files changed, 23 insertions(+), 10 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c<br>
> index 5290da4..507702a 100644<br>
> --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c<br>
> +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c<br>
> @@ -702,15 +702,20 @@ intel_miptree_map_gtt(struct intel_context *intel,<br>
> y /= bh;<br>
><br>
> base = intel_region_map(intel, mt->region, map->mode);<br>
> - /* Note that in the case of cube maps, the caller must have passed the slice<br>
> - * number referencing the face.<br>
> - */<br>
> - intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);<br>
> - x += image_x;<br>
> - y += image_y;<br>
><br>
> - map->stride = mt->region->pitch * mt->cpp;<br>
> - map->ptr = base + y * map->stride + x * mt->cpp;<br>
> + if (base == NULL)<br>
> + map->ptr = NULL;<br>
> + else {<br>
> + /* Note that in the case of cube maps, the caller must have passed the<br>
> + * slice number referencing the face.<br>
> + */<br>
> + intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);<br>
> + x += image_x;<br>
> + y += image_y;<br>
> +<br>
> + map->stride = mt->region->pitch * mt->cpp;<br>
> + map->ptr = base + y * map->stride + x * mt->cpp;<br>
> + }<br>
><br>
> DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__,<br>
> map->x, map->y, map->w, map->h,<br>
> @@ -1063,6 +1068,11 @@ intel_miptree_map(struct intel_context *intel,<br>
><br>
> *out_ptr = map->ptr;<br>
> *out_stride = map->stride;<br>
> +<br>
> + if (map->ptr == NULL) {<br>
> + mt->level[level].slice[slice].map = NULL;<br>
> + free(map);<br>
> + }<br>
> }<br>
><br>
> void<br>
> diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c<br>
> index bc83649..982d6cb 100644<br>
> --- a/src/mesa/drivers/dri/intel/intel_regions.c<br>
> +++ b/src/mesa/drivers/dri/intel/intel_regions.c<br>
> @@ -124,7 +124,7 @@ intel_region_map(struct intel_context *intel, struct intel_region *region,<br>
> */<br>
><br>
> _DBG("%s %p\n", __FUNCTION__, region);<br>
> - if (!region->map_refcount++) {<br>
> + if (!region->map_refcount) {<br>
> intel_flush(&intel->ctx);<br>
><br>
> if (region->tiling != I915_TILING_NONE)<br>
> @@ -133,7 +133,10 @@ intel_region_map(struct intel_context *intel, struct intel_region *region,<br>
> drm_intel_bo_map(region->bo, true);<br>
><br>
> region->map = region->bo->virtual;<br>
> - ++intel->num_mapped_regions;<br>
> + if (region->map) {<br>
> + ++intel->num_mapped_regions;<br>
> + region->map_refcount++;<br>
> + }<br>
> }<br>
><br>
> return region->map;<br>
<br>
</div></div>Any comments on this patch?<br>
</blockquote></div><div><br></div>I am planning to push this today.