summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/intel_regions.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-09-07 19:05:40 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-09-07 19:05:40 +0000
commit493b2ddecb47fdacc4b73d9c9a3ba2e46489105f (patch)
tree011c2f4570d336020c0db6562d294d638a981531 /src/mesa/drivers/dri/i965/intel_regions.c
parentc26f36c830cc6df1093a145eb43645f535004eb7 (diff)
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.
Diffstat (limited to 'src/mesa/drivers/dri/i965/intel_regions.c')
-rw-r--r--src/mesa/drivers/dri/i965/intel_regions.c63
1 files changed, 34 insertions, 29 deletions
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;
}
}