From f246dcd30a215339fd676cbc327fde976b630a7a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 7 Jun 2011 00:02:39 +0100 Subject: [PATCH] intel: Check the buffer is mappable at the time of creation --- src/mesa/drivers/dri/intel/intel_regions.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 0253bbc..a94f7a3 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -166,6 +166,16 @@ intel_region_alloc_internal(struct intel_screen *screen, return region; } +static bool intel_region_check_buffer_is_mappable(struct intel_screen *screen, + drm_intel_bo *buffer) +{ + size_t mappable, total; + + drm_intel_get_aperture_sizes(brw->intel.driFd, &mappable, &total); + + return buffer->size < mappable; +} + struct intel_region * intel_region_alloc(struct intel_screen *screen, uint32_t tiling, @@ -186,6 +196,12 @@ intel_region_alloc(struct intel_screen *screen, if (buffer == NULL) return NULL; + if (!intel_region_check_buffer_is_mappable(screen, buffer)) { + drm_intel_bo_unreference(buffer); + return NULL; + } + + region = intel_region_alloc_internal(screen, cpp, width, height, aligned_pitch / cpp, tiling, buffer); if (region == NULL) { -- 1.7.5.3