* The start index will be aligned simply from the fact that
* every sub-buffer in u_upload_mgr is aligned. */
userbuf = pipe->screen->user_buffer_create(pipe->screen,
- ptr + start, count * 2,
+ ptr, count * 2,
PIPE_BIND_INDEX_BUFFER);
indexBuffer = userbuf;
- r300_upload_index_buffer(r300, &indexBuffer, indexSize, 0, count, &start);
+ r300_upload_index_buffer(r300, &indexBuffer, indexSize, &start, count);
pipe_resource_reference(&userbuf, NULL);
}
pipe_buffer_unmap(pipe, transfer);
} else {
- r300_upload_index_buffer(r300, &indexBuffer, indexSize, start, count, &start);
+ if (r300_buffer_is_user_buffer(indexBuffer))
+ r300_upload_index_buffer(r300, &indexBuffer, indexSize, &start, count);
}
/* 19 dwords for emit_draw_elements. Give up if the function fails. */
return r300_buffer_is_referenced(context, buf, R300_REF_CS);
}
-/* External helper, not required to implent u_resource_vtbl:
- */
-int r300_upload_index_buffer(struct r300_context *r300,
- struct pipe_resource **index_buffer,
- unsigned index_size,
- unsigned start,
- unsigned count,
- unsigned *out_offset)
+void r300_upload_index_buffer(struct r300_context *r300,
+ struct pipe_resource **index_buffer,
+ unsigned index_size, unsigned *start,
+ unsigned count)
{
- struct pipe_resource *upload_buffer = NULL;
- unsigned index_offset = start * index_size;
- int ret = 0;
-
- if (r300_buffer_is_user_buffer(*index_buffer)) {
- ret = u_upload_buffer(r300->upload_ib,
- index_offset,
- count * index_size,
- *index_buffer,
- &index_offset,
- &upload_buffer);
- if (ret) {
- goto done;
- }
- *index_buffer = upload_buffer;
- *out_offset = index_offset / index_size;
- } else
- *out_offset = start;
-
- done:
- // if (upload_buffer)
- // pipe_resource_reference(&upload_buffer, NULL);
- return ret;
+ unsigned index_offset;
+ uint8_t *ptr = r300_buffer(*index_buffer)->user_buffer;
+
+ *index_buffer = NULL;
+
+ u_upload_data(r300->upload_ib,
+ count * index_size,
+ ptr + (*start * index_size),
+ &index_offset,
+ index_buffer);
+
+ *start = index_offset / index_size;
}
-/* External helper, not required to implement u_resource_vtbl:
- */
-int r300_upload_user_buffers(struct r300_context *r300)
+void r300_upload_user_buffers(struct r300_context *r300)
{
- enum pipe_error ret = PIPE_OK;
- int i, nr;
-
- nr = r300->velems->count;
+ int i, nr = r300->velems->count;
for (i = 0; i < nr; i++) {
struct pipe_vertex_buffer *vb =
&r300->vertex_buffer[r300->velems->velem[i].vertex_buffer_index];
if (r300_buffer_is_user_buffer(vb->buffer)) {
- struct pipe_resource *upload_buffer = NULL;
- unsigned offset = 0; /*vb->buffer_offset * 4;*/
- unsigned size = vb->buffer->width0;
- unsigned upload_offset;
- ret = u_upload_buffer(r300->upload_vb,
- offset, size,
- vb->buffer,
- &upload_offset, &upload_buffer);
- if (ret)
- return ret;
-
- pipe_resource_reference(&vb->buffer, NULL);
- vb->buffer = upload_buffer;
- vb->buffer_offset = upload_offset;
+ u_upload_data(r300->upload_vb,
+ vb->buffer->width0,
+ r300_buffer(vb->buffer)->user_buffer,
+ &vb->buffer_offset, &vb->buffer);
+
r300->validate_buffers = TRUE;
}
}
- return ret;
}
static void r300_buffer_destroy(struct pipe_screen *screen,
/* Functions. */
-int r300_upload_user_buffers(struct r300_context *r300);
+void r300_upload_user_buffers(struct r300_context *r300);
-int r300_upload_index_buffer(struct r300_context *r300,
- struct pipe_resource **index_buffer,
- unsigned index_size,
- unsigned start,
- unsigned count, unsigned *out_offset);
+void r300_upload_index_buffer(struct r300_context *r300,
+ struct pipe_resource **index_buffer,
+ unsigned index_size, unsigned *start,
+ unsigned count);
struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
const struct pipe_resource *templ);