}
-static enum pipe_error
-u_upload_alloc_buffer( struct u_upload_mgr *upload,
- unsigned min_size )
+static void
+u_upload_alloc_buffer(struct u_upload_mgr *upload,
+ unsigned min_size)
{
struct pipe_screen *screen = upload->pipe->screen;
struct pipe_resource buffer;
}
upload->buffer = screen->resource_create(screen, &buffer);
- if (upload->buffer == NULL) {
- return PIPE_ERROR_OUT_OF_MEMORY;
- }
+ if (upload->buffer == NULL)
+ return;
/* Map the new buffer. */
upload->map = pipe_buffer_map_range(upload->pipe, upload->buffer,
if (upload->map == NULL) {
upload->transfer = NULL;
pipe_resource_reference(&upload->buffer, NULL);
- return PIPE_ERROR_OUT_OF_MEMORY;
+ return;
}
upload->offset = 0;
- return PIPE_OK;
}
void
/* Make sure we have enough space in the upload buffer
* for the sub-allocation. */
if (unlikely(MAX2(upload->offset, alloc_offset) + alloc_size > buffer_size)) {
- enum pipe_error ret = u_upload_alloc_buffer(upload,
- alloc_offset + alloc_size);
- if (unlikely(ret != PIPE_OK)) {
+ u_upload_alloc_buffer(upload, alloc_offset + alloc_size);
+
+ if (unlikely(!upload->buffer)) {
*out_offset = ~0;
pipe_resource_reference(outbuf, NULL);
*ptr = NULL;
return PIPE_OK;
}
-
-/* As above, but upload the full contents of a buffer. Useful for
- * uploading user buffers, avoids generating an explosion of GPU
- * buffers if you have an app that does lots of small vertex buffer
- * renders or DrawElements calls.
- */
-enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
- unsigned min_out_offset,
- unsigned offset,
- unsigned size,
- struct pipe_resource *inbuf,
- unsigned *out_offset,
- struct pipe_resource **outbuf)
+/* XXX: Remove. It's basically a CPU fallback of resource_copy_region. */
+void u_upload_buffer(struct u_upload_mgr *upload,
+ unsigned min_out_offset,
+ unsigned offset,
+ unsigned size,
+ struct pipe_resource *inbuf,
+ unsigned *out_offset,
+ struct pipe_resource **outbuf)
{
- enum pipe_error ret = PIPE_OK;
struct pipe_transfer *transfer = NULL;
const char *map = NULL;
&transfer);
if (map == NULL) {
- return PIPE_ERROR_OUT_OF_MEMORY;
+ pipe_resource_reference(outbuf, NULL);
+ return;
}
if (0)
debug_printf("upload ptr %p ofs %d sz %d\n", map, offset, size);
- ret = u_upload_data( upload,
- min_out_offset,
- size,
- map,
- out_offset,
- outbuf);
-
+ u_upload_data(upload, min_out_offset, size, map, out_offset, outbuf);
pipe_buffer_unmap( upload->pipe, transfer );
-
- return ret;
}