diff options
author | Keith Whitwell <[email protected]> | 2009-05-07 09:24:37 +0100 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2009-05-08 10:04:14 +0100 |
commit | 4a333c64faf78dd39f07574bb94f62ba48995e7d (patch) | |
tree | 4ac64574f52cfc61670f8d6ca8d9e8076d5f8856 /src/gallium/auxiliary/util | |
parent | 5f5181021e50e830bc4a88cfd3f5249ad962619b (diff) |
util/upload: catch failures to map_range and return error
Caller may be able to do something about this - eg flush and retry.
Diffstat (limited to 'src/gallium/auxiliary/util')
-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 d9c0d7afa89..2eb98068c86 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: */ |