From 493b2ddecb47fdacc4b73d9c9a3ba2e46489105f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 7 Sep 2006 19:05:40 +0000 Subject: Cope with memory pool fragmentation by allowing a second attempt at rendering operations to take place after evicting all resident buffers. Cope better with memory allocation failures throughout the driver and improve tracking of failures. --- src/mesa/drivers/dri/i965/intel_regions.c | 63 +++++++++++++++++-------------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'src/mesa/drivers/dri/i965/intel_regions.c') diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c index 51495448ca..53f0561237 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.c +++ b/src/mesa/drivers/dri/i965/intel_regions.c @@ -52,6 +52,8 @@ GLubyte *intel_region_map(struct intel_context *intel, struct intel_region *regi DBG("%s\n", __FUNCTION__); if (!region->map_refcount++) { region->map = bmMapBuffer(intel, region->buffer, 0); + if (!region->map) + region->map_refcount--; } return region->map; @@ -198,15 +200,14 @@ void _mesa_copy_rect( GLubyte *dst, * * Currently always memcpy. */ -void intel_region_data(struct intel_context *intel, - struct intel_region *dst, - GLuint dst_offset, - GLuint dstx, GLuint dsty, - const void *src, GLuint src_pitch, - GLuint srcx, GLuint srcy, - GLuint width, GLuint height) +GLboolean intel_region_data(struct intel_context *intel, + struct intel_region *dst, + GLuint dst_offset, + GLuint dstx, GLuint dsty, + const void *src, GLuint src_pitch, + GLuint srcx, GLuint srcy, + GLuint width, GLuint height) { - DBG("%s\n", __FUNCTION__); if (width == dst->pitch && @@ -216,29 +217,33 @@ void intel_region_data(struct intel_context *intel, srcx == 0 && srcy == 0) { - bmBufferDataAUB(intel, - dst->buffer, - dst->cpp * width * dst->height, - src, - 0, - 0, /* DW_NOTYPE */ - 0); + return (bmBufferDataAUB(intel, + dst->buffer, + dst->cpp * width * dst->height, + src, 0, 0, 0) == 0); } else { - assert (dst_offset + dstx + width + - (dsty + height - 1) * dst->pitch * dst->cpp <= - dst->pitch * dst->cpp * dst->height); - - _mesa_copy_rect(intel_region_map(intel, dst) + dst_offset, - dst->cpp, - dst->pitch, - dstx, dsty, - width, height, - src, - src_pitch, - srcx, srcy); - - intel_region_unmap(intel, dst); + GLubyte *map = intel_region_map(intel, dst); + + if (map) { + assert (dst_offset + dstx + width + + (dsty + height - 1) * dst->pitch * dst->cpp <= + dst->pitch * dst->cpp * dst->height); + + _mesa_copy_rect(map + dst_offset, + dst->cpp, + dst->pitch, + dstx, dsty, + width, height, + src, + src_pitch, + srcx, srcy); + + intel_region_unmap(intel, dst); + return GL_TRUE; + } + else + return GL_FALSE; } } -- cgit v1.2.3