diff options
author | Keith Whitwell <keithw@vmware.com> | 2009-05-07 09:24:37 +0100 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2009-05-08 14:57:30 +0100 |
commit | e6a3801f3daaaf7e7e048ad0c43e838bac6a2d9a (patch) | |
tree | 15ebc3a3f0ffb5f5212de67b8001b2023bd4debd | |
parent | 222d7841e939d13bf29148c0cba5c7513050fa1e (diff) |
util/upload: catch failures to map_range and return error
Caller may be able to do something about this - eg flush and retry.
-rw-r--r-- | src/gallium/auxiliary/util/u_upload_mgr.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c index d9c0d7afa8..2eb98068c8 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/src/gallium/auxiliary/util/u_upload_mgr.c @@ -70,7 +70,7 @@ struct u_upload_mgr *u_upload_create( struct pipe_screen *screen, } -static INLINE void +static INLINE enum pipe_error my_buffer_write(struct pipe_screen *screen, struct pipe_buffer *buf, unsigned offset, unsigned size, unsigned dirty_size, @@ -84,12 +84,14 @@ my_buffer_write(struct pipe_screen *screen, assert(size); map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE); - assert(map); - if(map) { - memcpy(map + offset, data, size); - pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size); - pipe_buffer_unmap(screen, buf); - } + if (map == NULL) + return PIPE_ERROR_OUT_OF_MEMORY; + + memcpy(map + offset, data, size); + pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size); + pipe_buffer_unmap(screen, buf); + + return PIPE_OK; } /* Release old buffer. @@ -162,12 +164,14 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload, /* Copy the data, using map_range if available: */ - my_buffer_write( upload->screen, - upload->buffer, - upload->offset, - size, - alloc_size, - data ); + ret = my_buffer_write( upload->screen, + upload->buffer, + upload->offset, + size, + alloc_size, + data ); + if (ret) + return ret; /* Emit the return values: */ |