From 94d73d700e804ce78c214c58e84382c81dcb8280 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 11 Feb 2011 14:45:19 +0000 Subject: i965: interleaved vbo If the user passed in several arrays interleaved in the same vbo, only emit a single vertex buffer and relocation. Signed-off-by: Chris Wilson --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 39 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index be43dec9a4..587e74426f 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -319,18 +319,33 @@ static void brw_prepare_vertices(struct brw_context *brw) if (_mesa_is_bufferobj(input->glarray->BufferObj)) { struct intel_buffer_object *intel_buffer = intel_buffer_object(input->glarray->BufferObj); - struct brw_vertex_buffer *buffer = &brw->vb.buffers[j]; - - /* Named buffer object: Just reference its contents directly. */ - buffer->bo = intel_bufferobj_source(intel, intel_buffer, - &buffer->offset); - drm_intel_bo_reference(buffer->bo); - buffer->offset += (unsigned long)input->glarray->Ptr; - buffer->stride = input->glarray->StrideB; - + int k; + + for (k = 0; k < i; k++) { + struct brw_vertex_element *other = brw->vb.enabled[k]; + if (input->glarray->BufferObj == other->glarray->BufferObj && + input->glarray->StrideB == other->glarray->StrideB && + (uintptr_t)(input->glarray->Ptr - other->glarray->Ptr) < + input->glarray->StrideB) + { + input->buffer = other->buffer; + input->offset = input->glarray->Ptr - other->glarray->Ptr; + break; + } + } + if (k == i) { + struct brw_vertex_buffer *buffer = &brw->vb.buffers[j]; + /* Named buffer object: Just reference its contents directly. */ + buffer->bo = intel_bufferobj_source(intel, intel_buffer, + &buffer->offset); + drm_intel_bo_reference(buffer->bo); + buffer->offset += (uintptr_t)input->glarray->Ptr; + buffer->stride = input->glarray->StrideB; + + input->buffer = j++; + input->offset = 0; + } input->count = input->glarray->_MaxElement; - input->offset = 0; - input->buffer = j++; /* This is a common place to reach if the user mistakenly supplies * a pointer in place of a VBO offset. If we just let it go through, @@ -363,7 +378,7 @@ static void brw_prepare_vertices(struct brw_context *brw) ptr = input->glarray->Ptr; } else if (interleave != input->glarray->StrideB || - (GLuint)(input->glarray->Ptr - ptr) > interleave) + (uintptr_t)(input->glarray->Ptr - ptr) > interleave) { interleave = 0; } -- cgit v1.2.3