The return buffer or the returned pointer can be used instead.
Reviewed-by: Brian Paul <brianp@vmware.com>
return PIPE_OK;
}
-enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
- unsigned min_out_offset,
- unsigned size,
- unsigned *out_offset,
- struct pipe_resource **outbuf,
- void **ptr )
+void
+u_upload_alloc(struct u_upload_mgr *upload,
+ unsigned min_out_offset,
+ unsigned size,
+ unsigned *out_offset,
+ struct pipe_resource **outbuf,
+ void **ptr)
{
unsigned alloc_size = align(size, upload->alignment);
unsigned alloc_offset = align(min_out_offset, upload->alignment);
*out_offset = ~0;
pipe_resource_reference(outbuf, NULL);
*ptr = NULL;
- return ret;
+ return;
}
buffer_size = upload->buffer->width0;
*out_offset = ~0;
pipe_resource_reference(outbuf, NULL);
*ptr = NULL;
- return PIPE_ERROR_OUT_OF_MEMORY;
+ return;
}
upload->map -= offset;
*out_offset = offset;
upload->offset = offset + alloc_size;
- return PIPE_OK;
}
enum pipe_error u_upload_data( struct u_upload_mgr *upload,
struct pipe_resource **outbuf)
{
uint8_t *ptr;
- enum pipe_error ret = u_upload_alloc(upload, min_out_offset, size,
- out_offset, outbuf,
- (void**)&ptr);
- if (ret != PIPE_OK)
- return ret;
+
+ u_upload_alloc(upload, min_out_offset, size,
+ out_offset, outbuf,
+ (void**)&ptr);
+ if (!outbuf)
+ return PIPE_ERROR_OUT_OF_MEMORY;
memcpy(ptr, data, size);
return PIPE_OK;
* \param outbuf Pointer to where the upload buffer will be returned.
* \param ptr Pointer to the allocated memory that is returned.
*/
-enum pipe_error u_upload_alloc( struct u_upload_mgr *upload,
- unsigned min_out_offset,
- unsigned size,
- unsigned *out_offset,
- struct pipe_resource **outbuf,
- void **ptr );
+void u_upload_alloc(struct u_upload_mgr *upload,
+ unsigned min_out_offset,
+ unsigned size,
+ unsigned *out_offset,
+ struct pipe_resource **outbuf,
+ void **ptr);
/**
struct pipe_resource *out_buffer = NULL;
uint8_t *out_map;
unsigned out_offset, mask;
- enum pipe_error err;
/* Get a translate object. */
tr = translate_cache_find(mgr->translate_cache, key);
assert((ib->buffer || ib->user_buffer) && ib->index_size);
/* Create and map the output buffer. */
- err = u_upload_alloc(mgr->uploader, 0,
- key->output_stride * num_indices,
- &out_offset, &out_buffer,
- (void**)&out_map);
- if (err != PIPE_OK)
- return err;
+ u_upload_alloc(mgr->uploader, 0,
+ key->output_stride * num_indices,
+ &out_offset, &out_buffer,
+ (void**)&out_map);
+ if (!out_buffer)
+ return PIPE_ERROR_OUT_OF_MEMORY;
if (ib->user_buffer) {
map = (uint8_t*)ib->user_buffer + offset;
}
} else {
/* Create and map the output buffer. */
- err = u_upload_alloc(mgr->uploader,
- key->output_stride * start_vertex,
- key->output_stride * num_vertices,
- &out_offset, &out_buffer,
- (void**)&out_map);
- if (err != PIPE_OK)
- return err;
+ u_upload_alloc(mgr->uploader,
+ key->output_stride * start_vertex,
+ key->output_stride * num_vertices,
+ &out_offset, &out_buffer,
+ (void**)&out_map);
+ if (!out_buffer)
+ return PIPE_ERROR_OUT_OF_MEMORY;
out_offset -= key->output_stride * start_vertex;
tBot = (GLfloat) height;
}
- if (u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
- vbuf_offset, vbuf, (void **) &vertices) != PIPE_OK) {
+ u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
+ vbuf_offset, vbuf, (void **) &vertices);
+ if (!vbuf) {
return;
}
vb.stride = 8 * sizeof(float);
- if (u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
- &vb.buffer_offset, &vb.buffer,
- (void **) &vertices) != PIPE_OK) {
+ u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]),
+ &vb.buffer_offset, &vb.buffer,
+ (void **) &vertices);
+ if (!vb.buffer) {
return;
}
struct pipe_resource *buf = NULL;
unsigned offset;
- if (u_upload_alloc(st->uploader, 0, 4 * sizeof(verts[0]), &offset,
- &buf, (void **) &verts) != PIPE_OK) {
+ u_upload_alloc(st->uploader, 0, 4 * sizeof(verts[0]), &offset,
+ &buf, (void **) &verts);
+ if (!buf) {
return;
}
GLfloat *vbuf = NULL;
GLuint attr;
- if (u_upload_alloc(st->uploader, 0,
- numAttribs * 4 * 4 * sizeof(GLfloat),
- &offset, &vbuffer, (void **) &vbuf) != PIPE_OK) {
+ u_upload_alloc(st->uploader, 0,
+ numAttribs * 4 * 4 * sizeof(GLfloat),
+ &offset, &vbuffer, (void **) &vbuf);
+ if (!vbuffer) {
return;
}