summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_draw_upload.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-03-01 14:46:50 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-03-01 16:34:50 +0000
commit900a5c91eeb3acae7ee0ad331154531c4dba96e1 (patch)
treea14acdabe1d22ee26c639630bd40ee627581a06c /src/mesa/drivers/dri/i965/brw_draw_upload.c
parent9fa380ccdcf987430b9bff8e5216869e05b0aaea (diff)
i965: Use negative relocation deltas to minimse vertex uploads
With relaxed relocation checking in the kernel, we can specify a negative delta (i.e. pointing outside of the target bo) in order to fake a range in a large buffer. We only then need to upload the elements used and adjust the buffer offset such that they correspond with the indices used in the DrawArrays. (Depends on libdrm 0209428b3918c4336018da9293cdcbf7f8fedfb6) Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_draw_upload.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 1e129f98e0c..185f1ffa598 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -278,7 +278,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
GLuint interleaved = 0, total_size = 0;
unsigned int min_index = brw->vb.min_index;
unsigned int max_index = brw->vb.max_index;
- int i, j;
+ int delta, i, j;
struct brw_vertex_element *upload[VERT_ATTRIB_MAX];
GLuint nr_uploads = 0;
@@ -401,21 +401,25 @@ static void brw_prepare_vertices(struct brw_context *brw)
* only the used elements [min_index, max_index] so long as we adjust all
* the values used in the 3DPRIMITIVE i.e. by setting the vertex bias.
*/
+ brw->vb.start_vertex_bias = 0;
+ delta = min_index;
if (nr_uploads == brw->vb.nr_enabled) {
- brw->vb.start_vertex_bias = min_index;
- } else {
- brw->vb.start_vertex_bias = 0;
- min_index = 0;
+ brw->vb.start_vertex_bias = -delta;
+ delta = 0;
}
+ if (delta && !brw->intel.intelScreen->relaxed_relocations)
+ min_index = delta = 0;
/* Handle any arrays to be uploaded. */
if (nr_uploads > 1) {
if (interleaved && interleaved <= 2*total_size) {
+ struct brw_vertex_buffer *buffer = &brw->vb.buffers[j];
/* All uploads are interleaved, so upload the arrays together as
* interleaved. First, upload the contents and set up upload[0].
*/
copy_array_to_vbo_array(brw, upload[0], min_index, max_index,
- &brw->vb.buffers[j], interleaved);
+ buffer, interleaved);
+ buffer->offset -= delta * interleaved;
for (i = 0; i < nr_uploads; i++) {
/* Then, just point upload[i] at upload[0]'s buffer. */
@@ -462,14 +466,17 @@ static void brw_prepare_vertices(struct brw_context *brw)
intel_upload_unmap(&brw->intel, map, offset * count, offset,
&buffer->bo, &buffer->offset);
buffer->stride = offset;
+ buffer->offset -= delta * offset;
nr_uploads = 0;
}
}
/* Upload non-interleaved arrays */
for (i = 0; i < nr_uploads; i++) {
+ struct brw_vertex_buffer *buffer = &brw->vb.buffers[j];
copy_array_to_vbo_array(brw, upload[i], min_index, max_index,
- &brw->vb.buffers[j], upload[i]->element_size);
+ buffer, upload[i]->element_size);
+ buffer->offset -= delta * buffer->stride;
upload[i]->buffer = j++;
upload[i]->offset = 0;
}