aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-26 10:58:41 +0200
committermarha <marha@users.sourceforge.net>2011-10-26 10:58:41 +0200
commit4f005bade376d15ee60e90ca45a831aff9725087 (patch)
tree5abdbe5a7c55acf9e30c533414796f629fa9e47c /mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
parent9f986778bd4393c5a9108426969d45aa7f10f334 (diff)
downloadvcxsrv-4f005bade376d15ee60e90ca45a831aff9725087.tar.gz
vcxsrv-4f005bade376d15ee60e90ca45a831aff9725087.tar.bz2
vcxsrv-4f005bade376d15ee60e90ca45a831aff9725087.zip
libX11 libXft mesa mkfontscale pixman xserver git update 26 okt 2011
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util/u_upload_mgr.c')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_upload_mgr.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
index 71fe53e3a..a2319d0c4 100644
--- a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -131,8 +131,9 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
upload->bind,
PIPE_USAGE_STREAM,
size );
- if (upload->buffer == NULL)
- goto fail;
+ if (upload->buffer == NULL) {
+ return PIPE_ERROR_OUT_OF_MEMORY;
+ }
/* Map the new buffer. */
upload->map = pipe_buffer_map_range(upload->pipe, upload->buffer,
@@ -140,17 +141,16 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
PIPE_TRANSFER_WRITE |
PIPE_TRANSFER_FLUSH_EXPLICIT,
&upload->transfer);
-
+ if (upload->map == NULL) {
+ upload->size = 0;
+ pipe_resource_reference(&upload->buffer, NULL);
+ return PIPE_ERROR_OUT_OF_MEMORY;
+ }
+
upload->size = size;
upload->offset = 0;
- return 0;
-
-fail:
- if (upload->buffer)
- pipe_resource_reference( &upload->buffer, NULL );
-
- return PIPE_ERROR_OUT_OF_MEMORY;
+ return PIPE_OK;
}
enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
@@ -170,7 +170,7 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
if (MAX2(upload->offset, alloc_offset) + alloc_size > upload->size) {
enum pipe_error ret = u_upload_alloc_buffer(upload,
alloc_offset + alloc_size);
- if (ret)
+ if (ret != PIPE_OK)
return ret;
*flushed = TRUE;
@@ -187,6 +187,11 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
PIPE_TRANSFER_FLUSH_EXPLICIT |
PIPE_TRANSFER_UNSYNCHRONIZED,
&upload->transfer);
+ if (!upload->map) {
+ pipe_resource_reference(outbuf, NULL);
+ *ptr = NULL;
+ return PIPE_ERROR_OUT_OF_MEMORY;
+ }
}
assert(offset < upload->buffer->width0);
@@ -214,7 +219,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
enum pipe_error ret = u_upload_alloc(upload, min_out_offset, size,
out_offset, outbuf, flushed,
(void**)&ptr);
- if (ret)
+ if (ret != PIPE_OK)
return ret;
memcpy(ptr, data, size);
@@ -247,8 +252,7 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
&transfer);
if (map == NULL) {
- ret = PIPE_ERROR_OUT_OF_MEMORY;
- goto done;
+ return PIPE_ERROR_OUT_OF_MEMORY;
}
if (0)
@@ -261,9 +265,7 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
out_offset,
outbuf, flushed );
-done:
- if (map)
- pipe_buffer_unmap( upload->pipe, transfer );
+ pipe_buffer_unmap( upload->pipe, transfer );
return ret;
}