summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorAnuj Phogat <[email protected]>2012-02-27 11:09:29 -0800
committerAnuj Phogat <[email protected]>2012-03-20 15:11:39 -0700
commitcdcfd5d1d60179e60e3a0a47dda71bfe91083105 (patch)
treedcf55167abf9e34a3d3f9548a401bbb2b06d927e /src/mesa/drivers
parent2097af97288650f5aacd02b5ab09fd456579f882 (diff)
intel: Fix a case when mapping large texture fails
This patch handles a case when mapping a large texture fails in drm_intel_gem_bo_map_gtt(). These changes avoid assertion failure later in the driver as reported in following bugs: https://bugs.freedesktop.org/show_bug.cgi?id=44970 https://bugs.freedesktop.org/show_bug.cgi?id=46303 Testing: No regressions in piglit quick.tests Signed-off-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.c26
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.c7
2 files changed, 23 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 3601f5e8daf..636ee1797b0 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -702,15 +702,20 @@ intel_miptree_map_gtt(struct intel_context *intel,
y /= bh;
base = intel_region_map(intel, mt->region, map->mode);
- /* Note that in the case of cube maps, the caller must have passed the slice
- * number referencing the face.
- */
- intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
- x += image_x;
- y += image_y;
- map->stride = mt->region->pitch * mt->cpp;
- map->ptr = base + y * map->stride + x * mt->cpp;
+ if (base == NULL)
+ map->ptr = NULL;
+ else {
+ /* Note that in the case of cube maps, the caller must have passed the
+ * slice number referencing the face.
+ */
+ intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+ x += image_x;
+ y += image_y;
+
+ map->stride = mt->region->pitch * mt->cpp;
+ map->ptr = base + y * map->stride + x * mt->cpp;
+ }
DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__,
map->x, map->y, map->w, map->h,
@@ -1067,6 +1072,11 @@ intel_miptree_map(struct intel_context *intel,
*out_ptr = map->ptr;
*out_stride = map->stride;
+
+ if (map->ptr == NULL) {
+ mt->level[level].slice[slice].map = NULL;
+ free(map);
+ }
}
void
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index bc83649d608..d2b737b86c5 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -124,7 +124,7 @@ intel_region_map(struct intel_context *intel, struct intel_region *region,
*/
_DBG("%s %p\n", __FUNCTION__, region);
- if (!region->map_refcount++) {
+ if (!region->map_refcount) {
intel_flush(&intel->ctx);
if (region->tiling != I915_TILING_NONE)
@@ -133,7 +133,10 @@ intel_region_map(struct intel_context *intel, struct intel_region *region,
drm_intel_bo_map(region->bo, true);
region->map = region->bo->virtual;
- ++intel->num_mapped_regions;
+ if (region->map) {
+ intel->num_mapped_regions++;
+ region->map_refcount++;
+ }
}
return region->map;